Wiki
Clone wikienterobase-web / api_offset_parameter
Top level links:
- Main top level page for all documentation
- EnteroBase Features
- Registering on EnteroBase and logging in
- Tutorials
- Using the API
- About the underlying pipelines and other internals
- How schemes in EnteroBase work
- FAQ
The offset API parameter
Refer to interactive documentation : http://enterobase.warwick.ac.uk/api/v2.0/swagger-ui
offset
is a parameter for several query methods in the API and can have an integer value. The value specifies
a cursor position in the result from the underlying database query. Generally, the
offset
parameter would be used in conjunction with limit
.
Consider a somewhat artificial example (chosen so the result of the full query can in fact reasonably be fetched with a single use of the API query method). Supposing we wanted to step through the query
http://enterobase.warwick.ac.uk/api/v2.0/senterica/strains?serotype=Derby&only_fields=strain_name&reldate=3&sortorder=asc&orderby=barcode
giving the result
{ "Strains": [ { "strain_name": "2015K-0409" }, { "strain_name": "2015K-0383" }, { "strain_name": "2015K-0381" }, { "strain_name": "2015K-0374" }, { "strain_name": "2015K-0373" }, { "strain_name": "9454" }, { "strain_name": "73649" }, { "strain_name": "50140" }, { "strain_name": "HIY0126" }, { "strain_name": "H133220765" }, { "strain_name": "MDH-2014-00481" }, { "strain_name": "CFSAN012661" }, { "strain_name": "FSIS1500729" }, { "strain_name": "CVM-N15832" }, { "strain_name": "CVM N51280" }, { "strain_name": "CVM N48686" }, { "strain_name": "CVM N46856" }, { "strain_name": "CVM N45941" }, { "strain_name": "FSIS1503040" }, { "strain_name": "FSIS1501941" }, { "strain_name": "FSIS1501865" }, { "strain_name": "FSIS1504872" }, { "strain_name": "FSIS1503948" }, { "strain_name": "FSIS1503924" }, { "strain_name": "FSIS1503922" }, { "strain_name": "PNUSAS001733" }, { "strain_name": "PNUSAS001701" }, { "strain_name": "PNUSAS001704" }, { "strain_name": "PNUSAS002340" }, { "strain_name": "PNUSAS002235" }, { "strain_name": "BCW_2673" }, { "strain_name": "BCW_2053" }, { "strain_name": "BCW_2674" }, { "strain_name": "PNUSAS003899" }, { "strain_name": "PNUSAS003900" }, { "strain_name": "PNUSAS003896" }, { "strain_name": "PNUSAS007092" }, { "strain_name": "PNUSAS008100" }, { "strain_name": "FSIS1700527" }, { "strain_name": "FSIS1700353" }, { "strain_name": "FSIS1700364" }, { "strain_name": "FSIS1700611" } ], "links": { "paging": {}, "records": 42, "total_records": 42 } }
Then short consecutive chunks can be fetched by the query
http://enterobase.warwick.ac.uk/api/v2.0/senterica/strains?serotype=Derby&only_fields=strain_name&reldate=3&sortorder=asc&offset=0&orderby=barcode&limit=2
giving the result (the same as the result at the beginning of the earlier query without the limit parameter)
{ "Strains": [ { "strain_name": "2015K-0409" }, { "strain_name": "2015K-0383" } ], "links": { "paging": { "next": "http://enterobase.warwick.ac.uk/api/v2.0/senterica/strains?orderby=barcode&serotype=Derby&reldate=3&only_fields=strain_name&limit=2&sortorder=asc&offset=2" }, "records": 2, "total_records": 42 } }
and the query
http://enterobase.warwick.ac.uk/api/v2.0/senterica/strains?serotype=Derby&only_fields=strain_name&reldate=3&sortorder=asc&offset=2&orderby=barcode&limit=2
giving the result
{ "Strains": [ { "strain_name": "2015K-0381" }, { "strain_name": "2015K-0374" } ], "links": { "paging": { "next": "http://enterobase.warwick.ac.uk/api/v2.0/senterica/strains?orderby=barcode&serotype=Derby&reldate=3&only_fields=strain_name&limit=2&sortorder=asc&offset=4", "previous": "http://enterobase.warwick.ac.uk/api/v2.0/senterica/strains?orderby=barcode&serotype=Derby&reldate=3&only_fields=strain_name&limit=2&sortorder=asc&offset=2" }, "records": 2, "total_records": 42 } }
Updated