IDigBio API v1 Examples: Difference between revisions

change screenshot to "records" type →‎Display a thumbnail image for a mediarecord
(change screenshot to "records" type →‎Display a thumbnail image for a mediarecord)
Line 915: Line 915:
;TO DO One more paging to help differentiate these multiples of 5.
;TO DO One more paging to help differentiate these multiples of 5.


=== Display a thumbnail image for a mediarecord ===
=== Display a thumbnail image for a specimen record ===


Let's say that we wish to display a thumbnail image for a particular mediarecord.
Let's say that we wish to display a thumbnail image for a particular specimen record.


We can look at the full mediarecord:
We can look at the full record:


<pre>
<pre>
$ curl -s "http://api.idigbio.org/v1/mediarecords/00002091-4fb3-410a-9307-bd3e917dfcca" | json_pp  
$ curl -s "http://api.idigbio.org/v1/records/182c9260-0151-454a-a648-4d58ddf51bd8" | json_pp
{
{
   "idigbio:uuid" : "00002091-4fb3-410a-9307-bd3e917dfcca",
   "idigbio:uuid" : "182c9260-0151-454a-a648-4d58ddf51bd8",
   "idigbio:etag" : "90d98d48d9e7e07eab9064bd9b6e22ce6502c07f",
   "idigbio:etag" : "bb5ee46e2730948c946c178e8da85dedee4bea80",
   "idigbio:links" : {
   "idigbio:links" : {
      "mediarecord" : [
        "http://api.idigbio.org/v1/mediarecords/00002091-4fb3-410a-9307-bd3e917dfcca"
      ],
       "owner" : [
       "owner" : [
         "872733a2-67a3-4c54-aa76-862735a5f334"
         "872733a2-67a3-4c54-aa76-862735a5f334"
      ],
      "record" : [
        "http://api.idigbio.org/v1/records/182c9260-0151-454a-a648-4d58ddf51bd8"
       ],
       ],
       "recordset" : [
       "recordset" : [
Line 940: Line 940:
   "idigbio:createdBy" : "872733a2-67a3-4c54-aa76-862735a5f334",
   "idigbio:createdBy" : "872733a2-67a3-4c54-aa76-862735a5f334",
   "idigbio:recordIds" : [
   "idigbio:recordIds" : [
       "urn:uuid:2b6faee7-9f1d-47f3-97b2-fdcfd522ea9b"
       "urn:uuid:7d0d4400-7c6c-4bb4-b2ad-7b1f6e776755"
   ],
   ],
   "idigbio:dateModified" : "2014-05-03T14:45:47.112Z",
   "idigbio:dateModified" : "2014-05-03T14:27:40.596Z",
   "idigbio:data" : {
   "idigbio:data" : {
       "ac:accessURI" : "http://deliver.odai.yale.edu/content/repository/YPM/id/100973/format/3",
       "idigbio:recordId" : "urn:uuid:7d0d4400-7c6c-4bb4-b2ad-7b1f6e776755",
       "ac:metadataLanguage" : "en",
       "dwc:catalogNumber" : "CBS.038533",
       "ac:subtype" : "Photograph",
       "dwc:specificEpithet" : "novae-angliae",
       "dwc:occurrenceID" : "272024",
       "dwc:occurrenceID" : "272024",
       "xmpRights:WebStatement" : "http://hdl.handle.net/10079/8931zqj",
       "dwc:year" : "0",
       "dcterms:type" : "StillImage",
      "dwc:recordedBy" : "Hugh S. Clark",
       "xmp:MetadataDate" : "2012-10-08 20:53:21",
      "dwc:scientificName" : "Symphyotrichum novae-angliae",
       "xmpRights:UsageTerms" : "Yale Peabody Museum of Natural History",
      "dwc:basisOfRecord" : "PreservedSpecimen",
       "xmpRights:Owner" : "Peabody Museum of Natural History, Yale University",
      "dwc:family" : "Asteraceae",
       "dcterms:rights" : "http://hdl.handle.net/10079/8931zqj",
      "symbiotaverbatimScientificName" : "Symphyotrichum novae-angliae",
       "ac:providerManagedID" : "urn:uuid:2b6faee7-9f1d-47f3-97b2-fdcfd522ea9b",
       "dwc:collectionCode" : "CBS",
       "ac:associatedSpecimenReference" : "http://portal.neherbaria.org/portal/collections/individual/index.php?occid=272024"
       "dcterms:modified" : "2012-03-14 00:00:00",
       "dwc:decimalLongitude" : "-72.6834",
      "dwc:country" : "USA",
      "dcterms:references" : "http://portal.neherbaria.org/portal/collections/individual/index.php?occid=272024",
      "dwc:municipality" : "Hartford",
       "dwc:scientificNameAuthorship" : "(L.) G.L. Nesom",
      "dwc:month" : "0",
       "dwc:rights" : "http://hdl.handle.net/10079/8931zqj",
       "dwc:geodeticDatum" : "WGS84",
      "dwc:rightsHolder" : "Peabody Museum of Natural History, Yale University",
      "dwc:stateProvince" : "Connecticut",
      "dwc:genus" : "Symphyotrichum",
      "dwc:coordinateUncertaintyInMeters" : "5419",
      "dwc:decimalLatitude" : "41.766",
       "dwc:accessRights" : "http://hdl.handle.net/10079/8931zqj",
      "dwc:institutionCode" : "YPM",
      "dwc:county" : "Hartford County"
   }
   }
}
}
</pre>
</pre>


We will use the "media" endpoint for that mediarecord's iDigBio UUID and add the "quality" parameter with "thumbnail" as the value:
At this point we have a couple of options to get to the thumbnail. The easiest is to use the /media endpoint for this record's iDigBio UUID and add the "quality" parameter with "thumbnail" as the value:


http://api.idigbio.org/v1/mediarecords/00002091-4fb3-410a-9307-bd3e917dfcca/media?quality=thumbnail
http://api.idigbio.org/v1/records/182c9260-0151-454a-a648-4d58ddf51bd8/media?quality=thumbnail


which results in a number of HTTP Redirects to the target thumbnail image, illustrated here with the Chrome Developer Tools visible:
which results in a number of HTTP Redirects to the target thumbnail image, illustrated here with the Chrome Developer Tools visible:


[[File:Screenshot_thumbnail_00002091-4fb3-410a-9307-bd3e917dfcca.png]]
[[File:Screenshot_firefox_webdevtools_thumbnail_specimen_182c9260-0151-454a-a648-4d58ddf51bd8.png]]


''Note that the final image URL should not be considered stable or permanent. Images can be moved around to various storage platforms. The Mediarecord has a UUID that will remain contstant but the containing data, including the image location, may be updated over time.''
''Note that the final image URL should not be considered stable or permanent. Images can be moved around to various storage platforms. The Mediarecord has a UUID that will remain contstant but the containing data, including the image location, may be updated over time.''
The /media endpoint of a specimen record is kind of shortcut to avoid having to walk through the relationship to a mediarecord and then to an image file.
Alternatively, if we actually wanted to look at media metadata, we could use the link to the mediarecord in the <code>"idigbio:links"</code> section:
<pre>
  "idigbio:links" : {
      "mediarecord" : [
        "http://api.idigbio.org/v1/mediarecords/00002091-4fb3-410a-9307-bd3e917dfcca"
      ],
</pre>
which also has a /media endpoint that can lead to the same thumbnail image.
http://api.idigbio.org/v1/mediarecords/00002091-4fb3-410a-9307-bd3e917dfcca/media?quality=thumbnail


=== Advanced Elasticsearch Examples ===
=== Advanced Elasticsearch Examples ===
1,554

edits