Skip to main content

Pagination

All API resources have support for bulk fetches via list API methods. These methods share a common structure, which allows six additional parameters:

NameDefaultDescription
localeenIndicates the resource's desired localization
page1Indicates the list page to fetch
per_page100Indicates the desired results number on each page (max value is 100)
ids[]An array filter you can apply on the id field of results
sort_fields[]An array of fields to apply a specific sort on the results
sort_directions[]An array of integers (1 or -1) to specify the sort direction on each field in sort_fields
info

Actually locale parameter is used on few resource types

caution

When sorting, if you did not provide a direction for a field, AniAPI will use 1 as default

Resources structure#

Every Resource of AniAPI comes with a default set of fields:

NameDescription
creation_dateThe document's creation datetime
update_dateThe document's last update datetime
caution

These fields are not returned from API fetches. They are just used for sorting scopes.

Paginated response#

In order to give informations about the returned list of resources, AniAPI also provides pagination parameters inside the response's data field:

  • current_page, which tells you the current page number
  • count, indicating the number of total documents satisfying the filter
  • documents, an array containing the current page documents
  • last_page, to indicate the last page available to fetch
Example paginated response
{    "status_code": 200,    "message": "Page 1 contains 100 anime. Last page number is 161 for a total of 16094 anime",    "data": {        "current_page": 1,        "count": 16094,        "documents": [            {                // ...            },            {                // ...            },            // ...        ],        "last_page": 161    }}