pagination improved
This commit is contained in:
+13
-32
@@ -16,42 +16,23 @@ API keys should be added to the `API_KEYS` configuration option
|
||||
|
||||
## Pagination
|
||||
|
||||
Some resources may contain a large number of objects. Grabbing and handling them all in one request would be extremely inefficient both for the server and the user. Instead a technique known as pagination is used to break up the results into one or more pages of data.
|
||||
|
||||
There are two optional query parameters that can be used to control pagination:
|
||||
All resources that returns a list of objects has support for pagination. Some examples are search results, product listings and so on. To use the pagination there are two (optional) query parameters that you need to know about:
|
||||
|
||||
* `page` The page number starting from 1
|
||||
|
||||
* `per_page` The maxium number of items per page (default is 10)
|
||||
|
||||
Sample request:
|
||||
|
||||
`curl -X GET 'https://api2.photowall.com/designers/page=5&per_page=10'`
|
||||
|
||||
The response would look similar to this:
|
||||
An example request looks like this:
|
||||
|
||||
```
|
||||
{
|
||||
"page": 5,
|
||||
"per_page": 10,
|
||||
"data": [
|
||||
{
|
||||
"commission": 10,
|
||||
"commission_resale": 10,
|
||||
"currency": "SEK",
|
||||
"id": 68,
|
||||
"name": "kooo",
|
||||
"no_follow": 0,
|
||||
"path": "kiia-valikangas",
|
||||
"sort_desc": 0,
|
||||
"territory": "SE",
|
||||
"username": "kooo",
|
||||
"visible_designerpage": 1,
|
||||
"visible_list": 1,
|
||||
"visible_productpage": 1,
|
||||
"visible_search": 1
|
||||
},
|
||||
// results has been truncated for readability
|
||||
]
|
||||
}
|
||||
$ curl -X GET https://api2.photowall.com/designers/page=5&per_page=10 -u mykey
|
||||
```
|
||||
|
||||
The response will contain a pagination object with the following attributes:
|
||||
|
||||
* `page` The current page number
|
||||
* `pages` The total number of pages
|
||||
* `next_num` Number of the next page
|
||||
* `per_page` The number of items to be displayed on a page
|
||||
* `has_next` True if a next page exists
|
||||
* `has_prev` True if a previous page exists
|
||||
* `total` The total number of items
|
||||
Reference in New Issue
Block a user