IDigBio API v1 Examples: Difference between revisions

Line 109: Line 109:
</pre>
</pre>


=== Three ways to fetch a specific record based on iDigBio GUID ===
=== Three ways to fetch a specific record based on iDigBio UUID ===


The following three examples intend to illustrate the various methods for looking up a unique record in iDigBio and how the output may differ for the same record.
The following three examples intend to illustrate the various methods for looking up a unique record in iDigBio and how the output may differ for the same record.  Each record that is added to iDigBio is assigned a Globally Unique Identifier (GUID) of the UUID type.


The data returned by the Elasticsearch interface may differ from the raw API record, especially with regards to field names, since the Elasticsearch data has been normalized and indexed for consumption by the search portal.
The data returned by the Elasticsearch interface may differ from the raw API record, especially with regards to field names, since the Elasticsearch data has been normalized and indexed for consumption by the search portal.


For these three examples, consider the iDigBio specimen record identified by the following GUID:
Regardless of whether the record's data is retrieved by using the API or by using Elasticsearch, the piece of information used to identify a record is the iDigBio UUID.
 
For these three examples, consider the specimen record identified by the following iDigBio UUID:


<pre>
<pre>
Line 123: Line 125:
==== Use the API ====
==== Use the API ====


The complete record that was provided to iDigBio is stored in the API and can be retrieved by referencing the iDigBio GUID ("idigbio:uuid") as the entity ID at the '/records/{ID}' endpoint.
The complete record that was provided to iDigBio is stored in the API and can be retrieved by referencing the iDigBio UUID ("idigbio:uuid") as the entity ID at the '/records/{ID}' endpoint.


The following command sends the query as an HTTP <code> GET </code> request:
The following command sends the query as an HTTP <code> GET </code> request:
Line 193: Line 195:
==== Elasticsearch ====
==== Elasticsearch ====


The normalized and indexed record that is stored in Elasticsearch can be retrieved by referencing the iDigBio GUID ("uuid") as the term provided to the query string parameter.
The normalized and indexed record that is stored in Elasticsearch can be retrieved by referencing the iDigBio UUID ("uuid") as the term provided to the query string parameter.


The list of available terms in the iDigBio index is available at [[IDigBio_API#Elasticsearch_-_Records]].
The list of available terms in the iDigBio index is available at [[IDigBio_API#Elasticsearch_-_Records]].
Line 345: Line 347:
===== Use the Elasticsearch Request Body Search =====
===== Use the Elasticsearch Request Body Search =====


A JSON query document can be specified on the command-line. Again we are searching for the iDigBio GUID in the "uuid" term.
A JSON query document can be specified on the command-line. Again we are searching for the iDigBio UUID in the "uuid" term.


The following command sends the query as an HTTP <code> POST </code> request:
The following command sends the query as an HTTP <code> POST </code> request:
Line 502: Line 504:
</pre>
</pre>


Alternatively, the JSON-formatted query body can be stored in a file.  In this example, the file is named uuid.json and contains the iDigBio GUID in the "uuid" term as before:
Alternatively, the JSON-formatted query body can be stored in a file.  In this example, the file is named uuid.json and contains the iDigBio UUID in the "uuid" term as before:


<pre>
<pre>
1,554

edits