Pagination

Pagination lets you split large data list into several pages and specify the number of items displayed per page (the example for Users is provided).
To view the specific page, use the following request:

Example 1

XML Request Example

curl -i -X GET -u user:password --url http://onapp.test/users.xml/page/2 

JSON Request Example

curl -i -X GET -u user:password --url http://onapp.test/users.json/page/2

Example 2

XML Request Example

curl -i -X GET -u user:password --url http://83.170.110.181/users.xml?page=2

JSON Request Example

curl -i -X GET -u user:password --url http://83.170.110.181/users.json?page=2

Where you have to specify the URL and the number of page to display.


To specify the number of items displayed per page, use the following request:

Example 1

XML Request Example

curl -i -X GET -u user:password --url http://onapp.test/users.xml/per_page/4

JSON Request Example

curl -i -X GET -u user:password --url http://onapp.test/users.json/per_page/4

Example 2

XML Request Example

curl -i -X GET -u user:password --url http://83.170.110.181/users.xml?per_page=4

JSON Request Example

curl -i -X GET -u user:password --url http://83.170.110.181/users.json?per_page=4

Where you have to specify the URL and the number of items to display per page.


To specify the page number and the number of items displayed per page, run one of the following requests:

Example 1

XML Request Example

curl -i -X GET -u user:password --url http://83.170.110.181/users.xml/page/2/per_page/4

JSON Request Example

curl -i -X GET -u user:password --url http://83.170.110.181/users.json/page/2/per_page/4

Example 2

XML Request Example

curl -i -X GET -u user:password --url http://83.170.110.181/users.xml/per_page/4/page/2

JSON Request Example

curl -i -X GET -u user:password --url http://83.170.110.181/users.json/per_page/4/page/2

Example 3

XML Request Example

curl -i -X GET -u user:password --url http://83.170.110.181/users.xml?page=2&per_page=4

JSON Request Example

curl -i -X GET -u user:password --url http://83.170.110.181/users.json?page=2&per_page=4

Where you'll have to specify the page URL, page number and amount of items displayed per page.


XML Output Example

curl -i -X GET -u user:password --url http://83.170.110.181/users.json/per_page/2/page/4
HTTP/1.1 200 OK
Date: Mon, 25 Jun 2012 09:43:35 GMT
Server: Apache/2.2.3 (CentOS)
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.9
X-Total: 37
X-Limit: 2
X-Page: 4
X-UA-Compatible: IE=Edge,chrome=1
ETag: "3eec8dfd2f935df854612cd39a03f49a"
Cache-Control: must-revalidate, private, max-age=0
X-Request-Id: bb7162179190b3f21897542495d3e72b
X-Runtime: 0.187337
X-Rack-Cache: miss
Set-Cookie: _session_id=41fdb2fe690dcd4a8ba04af1902305b6; path=/; HttpOnly
Status: 200
Connection: close
Transfer-Encoding: chunked
Content-Type: application/json; charset=utf-8 


Where:

X-Total – the total number of displayed items

X-Limit – the number of items displayed per page

X-Page – the page number