IDigBio API v1 Examples: Difference between revisions

Jump to navigation Jump to search
Line 1,072: Line 1,072:
# "hasImage" is true
# "hasImage" is true
# "county" is either "Hocking" or "Fairfield"
# "county" is either "Hocking" or "Fairfield"
# "stateprovince" is equal to "Ohio" (there are multiple Fairfield counties throughout the world so we need to restrict the geography by state)
# "stateprovince" is "Ohio" (there are multiple Fairfield counties throughout the world so we need to restrict the geography by state)


The essential query parameter string will look something like this:
The essential query parameter string will look something like this (note we must lowercase the values):


<pre>
<pre>
Line 1,080: Line 1,080:
</pre>
</pre>


In addition, it is possible to request more or fewer records at a time using the "from" and "size" parameters.  Below is the full curl example requesting only the first 3 records and grep'ing out only the iDigBio UUID field. Note that we put the URL in quotes to keep the shell from trying to interpret it.
In addition, it is possible to request more or fewer records at a time using the "from" and "size" parameters.  Below is the full curl example requesting only the first 3 records and using grep on the output to filter everything except the iDigBio UUID field. Note that we quote the full URL to keep the shell from trying to interpret the special characters.


<pre>
<pre>
$ curl -s "http://search.idigbio.org/idigbio/records/_search?from=0&size=3&q=hasImage:true+AND+county:(fairfield+OR+hocking)+AND+stateprovince:ohio" | json_pp  | egrep "\"uuid\""  
$ curl -s 'http://search.idigbio.org/idigbio/records/_search?from=0&size=3&q=hasImage:true+AND+county:(fairfield+OR+hocking)+AND+stateprovince:ohio' | json_pp  | egrep "\"uuid\""  
              "uuid" : "ecf14f53-d225-4eb5-89e6-66379b360781",
              "uuid" : "e45071cd-40eb-41e7-9105-0e35234025f5",
               "uuid" : "20ad60a8-4126-4cc0-9378-411a9a640005",
               "uuid" : "20ad60a8-4126-4cc0-9378-411a9a640005",
              "uuid" : "ecf14f53-d225-4eb5-89e6-66379b360781",
              "uuid" : "ff69483e-ab19-4fa7-9ca3-d99089280af6",
</pre>
</pre>


Now that we have iDigBio UUIDs, we could retrieve images for these specimens by iterating over the /media endpoints for each of those uuids in the API.
Now that we have iDigBio UUIDs, we could retrieve images for these specimens by iterating over the /media endpoints for each of those uuids in the API.


http://api.idigbio.org/v1/records/20ad60a8-4126-4cc0-9378-411a9a640005/media?quality=webview
http://api.idigbio.org/v1/records/ecf14f53-d225-4eb5-89e6-66379b360781/media?quality=webview


http://api.idigbio.org/v1/records/ecf14f53-d225-4eb5-89e6-66379b360781/media?quality=webview
http://api.idigbio.org/v1/records/e45071cd-40eb-41e7-9105-0e35234025f5/media?quality=webview


...
...


Note that we did not specify any sorting in the Elasticsearch query and restricted the result count using the "size" parameter. If the same query is run at a later time the specific records returned could be different.


; 2. We plan to continue adding examples to this page...
; 2. We plan to continue adding examples to this page...
1,554

edits

Navigation menu