Paginating with limits and offsets

From DreamFactory
Jump to: navigation, search
DreamFactoryTutorialsPaginating with limits and offsets
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
### Tutorial
 
 
 
Use limit and offset parameters to paginate records in a GET request. Try these examples in the 'API Docs' tab of the DreamFactory Admin Console or from the command line with cURL.
 
Use limit and offset parameters to paginate records in a GET request. Try these examples in the 'API Docs' tab of the DreamFactory Admin Console or from the command line with cURL.
  
 
Note that offset i returns record i+1 as the first record in the set (for example, offset = 0 returns record 1 as the first record in the set, offset =10 returns record 11 as the first record in the set, and so forth).
 
Note that offset i returns record i+1 as the first record in the set (for example, offset = 0 returns record 1 as the first record in the set, offset =10 returns record 11 as the first record in the set, and so forth).
  
### API Endpoint
+
=== API Endpoint ===
  
 
<pre>GET https://{url}/api/v2/{api_name}/_table/{table_name}?limit={record_limit}&offset={offset_number}</pre>
 
<pre>GET https://{url}/api/v2/{api_name}/_table/{table_name}?limit={record_limit}&offset={offset_number}</pre>
  
### API Docs Screenshot
+
=== API Docs Screenshot ===
  
 
[[File:Swagger-limit.png|1000px]] <br>
 
[[File:Swagger-limit.png|1000px]] <br>
 
[[File:Swagger-offset.png|1000px]]
 
[[File:Swagger-offset.png|1000px]]
  
### Example - GET the first set of ten contact records (records 1 through 10, inclusive)
+
=== Example - GET the first set of ten contact records (records 1 through 10, inclusive) ===
  
 
* Table name: contact
 
* Table name: contact
Line 21: Line 19:
 
* Request URL: <pre>https://foo.com/api/v2/db/_table/contact?limit=10&offset=0</pre>
 
* Request URL: <pre>https://foo.com/api/v2/db/_table/contact?limit=10&offset=0</pre>
  
### Example - GET the second set of ten contact records (records 11 through 20, inclusive)
+
=== Example - GET the second set of ten contact records (records 11 through 20, inclusive) ===
  
 
* Table name: contact
 
* Table name: contact

Latest revision as of 20:12, 22 June 2016

Use limit and offset parameters to paginate records in a GET request. Try these examples in the 'API Docs' tab of the DreamFactory Admin Console or from the command line with cURL.

Note that offset i returns record i+1 as the first record in the set (for example, offset = 0 returns record 1 as the first record in the set, offset =10 returns record 11 as the first record in the set, and so forth).

API Endpoint

GET https://{url}/api/v2/{api_name}/_table/{table_name}?limit={record_limit}&offset={offset_number}

API Docs Screenshot

Swagger-limit.png
Swagger-offset.png

Example - GET the first set of ten contact records (records 1 through 10, inclusive)

  • Table name: contact
  • Limit parameter in API call:
    10
  • Offset parameter in API call:
    0
  • Request URL:
    https://foo.com/api/v2/db/_table/contact?limit=10&offset=0

Example - GET the second set of ten contact records (records 11 through 20, inclusive)

  • Table name: contact
  • Limit parameter in API call:
    10
  • Offset parameter in API call:
    10
  • Request URL:
    https://foo.com/api/v2/db/_table/contact?limit=10&offset=10