1,554
edits
m (add quotes around url with query string) |
(add new example and simply some curls) |
||
Line 79: | Line 79: | ||
<pre> | <pre> | ||
$ curl -s | $ curl -s https://api.idigbio.org/v1/records/0cec43d8-9ad5-478a-bea1-397ab5cc4430 | json_pp | ||
{ | { | ||
"idigbio:uuid" : "0cec43d8-9ad5-478a-bea1-397ab5cc4430", | "idigbio:uuid" : "0cec43d8-9ad5-478a-bea1-397ab5cc4430", | ||
Line 151: | Line 151: | ||
<pre> | <pre> | ||
$ curl -s | $ curl -s "https://search.idigbio.org/idigbio/records/_search?q=uuid:0cec43d8-9ad5-478a-bea1-397ab5cc4430" | json_pp | ||
{ | { | ||
"hits" : { | "hits" : { | ||
Line 159: | Line 159: | ||
"collectioncode" : "plants", | "collectioncode" : "plants", | ||
"datecollected" : "1985-03-14", | "datecollected" : "1985-03-14", | ||
"recordids" : [ | |||
"urn:uuid:5f5e476f-ee39-41c9-8b25-c929f85a773a" | |||
], | |||
"geopoint" : { | |||
"lat" : 23.5821004818154, | |||
"lon" : -105.859665870667 | |||
}, | |||
"uuid" : "0cec43d8-9ad5-478a-bea1-397ab5cc4430", | "uuid" : "0cec43d8-9ad5-478a-bea1-397ab5cc4430", | ||
"locality" : "ca. 1 mi n of hwy 40 between villa union and cd. durango, and ca. 5 mi w of durango state border.", | "locality" : "ca. 1 mi n of hwy 40 between villa union and cd. durango, and ca. 5 mi w of durango state border.", | ||
"minelevation" : | "minelevation" : 2316, | ||
"collectionid" : "urn:uuid:a2e32c87-d320-4a01-bafd-a9182ae2e191", | "collectionid" : "urn:uuid:a2e32c87-d320-4a01-bafd-a9182ae2e191", | ||
"datecollected_rejected" : false, | "datecollected_rejected" : false, | ||
"datemodified_rejected" : false, | "datemodified_rejected" : false, | ||
"recordset" : "40250f4d-7aa6-4fcc-ac38-2868fa4846bd", | "recordset" : "40250f4d-7aa6-4fcc-ac38-2868fa4846bd", | ||
"mediarecords" : [ | |||
"db38f86b-99f5-4dc4-b4a6-a045a9c35323" | |||
], | |||
"stateprovince" : "sinaloa", | |||
"country" : "mexico", | |||
"collector" : "t. f. daniel;", | |||
"geopoint_rejected" : false, | "geopoint_rejected" : false, | ||
"hasImage" : true, | "hasImage" : true, | ||
"genus" : "abies", | |||
"data" : { | "data" : { | ||
"idigbio:uuid" : "0cec43d8-9ad5-478a-bea1-397ab5cc4430", | "idigbio:uuid" : "0cec43d8-9ad5-478a-bea1-397ab5cc4430", | ||
Line 249: | Line 261: | ||
"idigbio:dateModified" : "2014-04-20T23:11:09.437Z" | "idigbio:dateModified" : "2014-04-20T23:11:09.437Z" | ||
}, | }, | ||
"datemodified" : "2014-04-20", | |||
"scientificname" : "abies", | "scientificname" : "abies", | ||
"minelevation_rejected" : false, | "minelevation_rejected" : false, | ||
"catalognumber" : "asu0000166", | |||
"etag" : "2682a8f2fb77d59d50442925a80fe58a2ad51e9c", | "etag" : "2682a8f2fb77d59d50442925a80fe58a2ad51e9c", | ||
"mindepth_rejected" : false, | |||
"maxelevation_rejected" : false, | |||
"maxdepth_rejected" : false, | "maxdepth_rejected" : false, | ||
"recordnumber" : "4031", | |||
"family" : "pinaceae", | "family" : "pinaceae", | ||
"institutioncode" : "asu" | "institutioncode" : "asu" | ||
}, | }, | ||
"_score" : 14. | "_score" : 14.687269, | ||
"_index" : "idigbio-1. | "_index" : "idigbio-1.1.0", | ||
"_id" : "0cec43d8-9ad5-478a-bea1-397ab5cc4430", | "_id" : "0cec43d8-9ad5-478a-bea1-397ab5cc4430", | ||
"_type" : "records" | "_type" : "records" | ||
} | } | ||
], | ], | ||
"max_score" : 14. | "max_score" : 14.687269, | ||
"total" : 1 | "total" : 1 | ||
}, | }, | ||
Line 291: | Line 288: | ||
"total" : 10 | "total" : 10 | ||
}, | }, | ||
"took" : | "took" : 5 | ||
} | } | ||
</pre> | </pre> | ||
Line 308: | Line 305: | ||
</pre> | </pre> | ||
We get the same results in the data fields as the previous search: | To convince curl to use the <code> GET </code> HTTP method instead of <code> POST </code> HTTP method when invoked with the -d option, we add the additional <code> -X </code> option and specify the <code>GET</code> method. We get the same results in the data fields as the previous search: | ||
<pre> | <pre> | ||
Line 452: | Line 449: | ||
}, | }, | ||
"took" : 64 | "took" : 64 | ||
} | |||
</pre> | |||
=== Fetch an Older Version of a Particular Media Record === | |||
Consider an iDigBio Media Record "idigbio:uuid" : "ff5fd841-6bc6-4241-80d3-def7e1b6d5e8" with multiple revisions of the record. The API shows that the current version of this particular record is version 1. | |||
<pre> | |||
$ curl -s http://api.idigbio.org/v1/mediarecords/ff5fd841-6bc6-4241-80d3-def7e1b6d5e8 | json_pp | grep version | |||
"idigbio:version" : 1, | |||
</pre> | |||
We would like to look at the previous version (version 0) to see what has changed. We do this by adding <code>?version=0</code> as a parameter to the URL. | |||
<pre> | |||
$ curl -s http://api.idigbio.org/v1/mediarecords/ff5fd841-6bc6-4241-80d3-def7e1b6d5e8?version=0 | json_pp | |||
{ | |||
"idigbio:uuid" : "ff5fd841-6bc6-4241-80d3-def7e1b6d5e8", | |||
"idigbio:etag" : "0a9effd5fc2803e87e4236e03a33ba3d00c3b305", | |||
"idigbio:links" : { | |||
"owner" : [ | |||
"872733a2-67a3-4c54-aa76-862735a5f334" | |||
], | |||
"record" : [ | |||
"http://api.idigbio.org/v1/records/aebc99d6-3ba8-4d55-9434-83364b98d9b6" | |||
], | |||
"recordset" : [ | |||
"http://api.idigbio.org/v1/recordsets/e70af26a-fb9e-43ab-96a0-d62a2df37e6d" | |||
] | |||
}, | |||
"idigbio:version" : "0", | |||
"idigbio:createdBy" : "872733a2-67a3-4c54-aa76-862735a5f334", | |||
"idigbio:recordIds" : [ | |||
"e70af26a-fb9e-43ab-96a0-d62a2df37e6d\\media\\urn:catalog:UConn:CONN:Image:CONN00175018" | |||
], | |||
"idigbio:dateModified" : "2014-03-05T23:38:31.326Z", | |||
"idigbio:data" : { | |||
"ac:licenseLogoURL" : "http://mirrors.creativecommons.org/presskit/buttons/80x15/png/by-nc-sa.png", | |||
"ac:metadataLanguage" : "eng", | |||
"dwc:occurrenceID" : "urn:catalog:UConn:CONN:CONN00175018", | |||
"xmpRights:WebStatement" : "http://creativecommons.org/licenses/by-nc-sa/4.0/", | |||
"ac:bestQualityAccessURI" : "http://bgbaseserver.eeb.uconn.edu/DATABASEIMAGES/CONN00175018.JPG", | |||
"ac:bestQualityFormat" : "image/jpeg", | |||
"dcterms:creator" : "CONN", | |||
"dcterms:type" : "StillImage", | |||
"xmpRights:Owner" : "G. S. Torrey Herbarium, University of Connecticut", | |||
"dcterms:rights" : "© 2003 University of Connecticut", | |||
"dcterms:title" : "specimen image", | |||
"dcterms:identifier" : "urn:catalog:UConn:CONN:Image:CONN00175018" | |||
} | |||
} | } | ||
</pre> | </pre> |
edits