IDigBio API v1 Examples: Difference between revisions

move paging example here so it can be removed from the specification
(replace GUID with UUID in most places)
(move paging example here so it can be removed from the specification)
Line 754: Line 754:


[[File:Screenshot_jsonview_idigbio_api_mediarecords_limit_offset.png]]
[[File:Screenshot_jsonview_idigbio_api_mediarecords_limit_offset.png]]
=== Paging through API lists ===
Request 5 media record entities:
<pre>
$ curl -s "http://api.idigbio.org/v1/mediarecords?limit=5" | json_pp
{
  "idigbio:errors" : [],
  "idigbio:links" : {
      "idigbio:nextPage" : "http://api.idigbio.org/v1/mediarecords?limit=5&offset=5"
  },
  "idigbio:items" : [
      {
        "idigbio:links" : {
            "mediarecord" : "http://api.idigbio.org/v1/mediarecords/000003cd-0cca-421b-8f26-f557a26b0393"
        },
        "idigbio:uuid" : "000003cd-0cca-421b-8f26-f557a26b0393",
        "idigbio:version" : 1,
        "idigbio:etag" : "ce3e2f7272ec996bb479c87549ba90c15ba96426",
        "idigbio:dateModified" : "2014-04-21T22:19:27.436Z"
      },
      {
        "idigbio:links" : {
            "mediarecord" : "http://api.idigbio.org/v1/mediarecords/00000728-ffb3-4a68-9f93-137f19961121"
        },
        "idigbio:uuid" : "00000728-ffb3-4a68-9f93-137f19961121",
        "idigbio:version" : 3,
        "idigbio:etag" : "ef2cac326a60d89d8cb9005abaa82068bfa83565",
        "idigbio:dateModified" : "2014-04-24T05:03:56.782Z"
      },
      {
        "idigbio:links" : {
            "mediarecord" : "http://api.idigbio.org/v1/mediarecords/00000b03-e208-4d22-983b-506ad2842f7c"
        },
        "idigbio:uuid" : "00000b03-e208-4d22-983b-506ad2842f7c",
        "idigbio:version" : 2,
        "idigbio:etag" : "bc118a7ea53e004c82ab9b7e813e1010ae5f8e17",
        "idigbio:dateModified" : "2014-04-20T05:16:20.389Z"
      },
      {
        "idigbio:links" : {
            "mediarecord" : "http://api.idigbio.org/v1/mediarecords/000010bc-a4d4-483d-b71d-0dbdd4fd2d5a"
        },
        "idigbio:uuid" : "000010bc-a4d4-483d-b71d-0dbdd4fd2d5a",
        "idigbio:version" : 0,
        "idigbio:etag" : "68c441bd3c49507bf930f3b278f2c58f9cb792ec",
        "idigbio:dateModified" : "2014-04-20T21:38:46.679Z"
      },
      {
        "idigbio:links" : {
            "mediarecord" : "http://api.idigbio.org/v1/mediarecords/000012f9-d288-4a14-b898-77430e0a137a"
        },
        "idigbio:uuid" : "000012f9-d288-4a14-b898-77430e0a137a",
        "idigbio:version" : 1,
        "idigbio:etag" : "cf49416750fdb9bdb808c334a74b84f27bb8160b",
        "idigbio:dateModified" : "2014-04-23T02:43:08.344Z"
      }
  ],
  "idigbio:itemCount" : "2342880"
}
</pre>
The next "page" of records can be requested by adding the "offset" paramenter.
A link that includes the offset to the next page is provided in the results:
<pre>
  "idigbio:links" : {
      "idigbio:nextPage" : "http://api.idigbio.org/v1/mediarecords?limit=5&offset=5"
  }
</pre>
Request the next "page" of entity ids by starting at offset 5.
<pre>
$ curl -s "http://api.idigbio.org/v1/mediarecords?limit=5&offset=5" | json_pp
{
  "idigbio:errors" : [],
  "idigbio:links" : {
      "idigbio:nextPage" : "http://api.idigbio.org/v1/mediarecords?limit=5&offset=10",
      "idigbio:prevPage" : "http://api.idigbio.org/v1/mediarecords?limit=5&offset=0"
  },
  "idigbio:items" : [
      {
        "idigbio:links" : {
            "mediarecord" : "http://api.idigbio.org/v1/mediarecords/00001478-c150-4faf-a617-439a838d4377"
        },
        "idigbio:uuid" : "00001478-c150-4faf-a617-439a838d4377",
        "idigbio:version" : 1,
        "idigbio:etag" : "30f602e4eb47ebb2ceb265f64217e3cf5664f517",
        "idigbio:dateModified" : "2014-03-21T23:09:39.752Z"
      },
      {
        "idigbio:links" : {
            "mediarecord" : "http://api.idigbio.org/v1/mediarecords/00001a91-189b-4002-b56e-a770a55951a0"
        },
        "idigbio:uuid" : "00001a91-189b-4002-b56e-a770a55951a0",
        "idigbio:version" : 0,
        "idigbio:etag" : "647e82d17ee435fb14f0f8607dabe88dfc3a1944",
        "idigbio:dateModified" : "2014-04-25T04:49:32.359Z"
      },
      {
        "idigbio:links" : {
            "mediarecord" : "http://api.idigbio.org/v1/mediarecords/00002091-4fb3-410a-9307-bd3e917dfcca"
        },
        "idigbio:uuid" : "00002091-4fb3-410a-9307-bd3e917dfcca",
        "idigbio:version" : 0,
        "idigbio:etag" : "90d98d48d9e7e07eab9064bd9b6e22ce6502c07f",
        "idigbio:dateModified" : "2014-05-03T18:45:47.112Z"
      },
      {
        "idigbio:links" : {
            "mediarecord" : "http://api.idigbio.org/v1/mediarecords/00002c32-ae3a-41ed-9bd9-f6c50d3e35fb"
        },
        "idigbio:uuid" : "00002c32-ae3a-41ed-9bd9-f6c50d3e35fb",
        "idigbio:version" : 3,
        "idigbio:etag" : "d1ded90d06e93876b1badd01222905add93e8806",
        "idigbio:dateModified" : "2014-04-19T00:25:59.471Z"
      },
      {
        "idigbio:links" : {
            "mediarecord" : "http://api.idigbio.org/v1/mediarecords/00002dbd-6415-463b-8cae-38f548415ffa"
        },
        "idigbio:uuid" : "00002dbd-6415-463b-8cae-38f548415ffa",
        "idigbio:version" : 2,
        "idigbio:etag" : "4e298045b496146f5c51e331c9887fd7afde4deb",
        "idigbio:dateModified" : "2014-04-21T20:29:39.531Z"
      }
  ],
  "idigbio:itemCount" : "2342880"
}
</pre>
which includes links to the previous page and next page:
<pre>
      "idigbio:nextPage" : "http://api.idigbio.org/v1/mediarecords?limit=5&offset=10",
      "idigbio:prevPage" : "http://api.idigbio.org/v1/mediarecords?limit=5&offset=0"
</pre>
With current results starting at offset 5 and a limit of 5, the previous page and a next page offsets are 0 and 10 respectively (offset +- limit).
;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 mediarecord ===
1,554

edits