IDigBio API v1 Specification: Difference between revisions

detailed paging example is moving to the Examples page →‎GET /v1/mediarecords
(detailed paging example is moving to the Examples page →‎GET /v1/mediarecords)
Line 205: Line 205:
}
}
</pre>
</pre>


One point of interest here is that <code> "idigbio:itemCount" </code> contains the number of items of this type in the API. In this case, there are 2,342,880 mediarecords total in the API.
One point of interest here is that <code> "idigbio:itemCount" </code> contains the number of items of this type in the API. In this case, there are 2,342,880 mediarecords total in the API.


 
The next "page" of records can be requested by adding the "offset" parameter, which is already provided in the "links" section of the returned data:
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>
<pre>
Line 220: Line 216:
</pre>
</pre>


Request the next "page" of entity ids by starting at offset 5.
More thorough examples of using the nextPage and prevPage links as well as "offset" and "limit" are in [[iDigBio API Examples]].
 
<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).


''DO NOT expect to be able to page through the entire iDigBio data this way.  See [[iDigBio API Performance]] if you find yourself trying to page through large amounts of data.''
''DO NOT expect to be able to page through the entire iDigBio data this way.  See [[iDigBio API Performance]] if you find yourself trying to page through large amounts of data.''
1,554

edits