# Pagination

All API v2.0 list endpoints return paginated responses by default. This improves performance and ensures that large datasets can be retrieved efficiently.

***

## How Pagination Works

Every list endpoint responds with a standardized JSON structure that includes:

* `count`: the total number of matching records
* `next`: the URL to fetch the next page (or `null` if there is no next page)
* `previous`: the URL to fetch the previous page (or `null` if you are on the first page)
* `results`: an array containing the records in the current page

***

## Example Paginated Response of a Case Query:

```json
{
  "count": 473,
  "next": "https://clearinghouse.net/api/v2/case/?case_type=5039&page=3",
  "previous": "https://clearinghouse.net/api/v2/case/?case_type=5039&page=1",
  "results": [
    {
      "id": 15150,
      "name": "Pottinger v. City of Miami",
      "case_documents_url": "https://clearinghouse.net/api/v2/documents/?case=15150", // URL to retrieve documents related to this case.
      "case_dockets_url": "https://clearinghouse.net/api/v2/dockets/?case=15150", // URL to retrieve dockets related to this case.
      "case_resources_url": "https://clearinghouse.net/api/v2/resources/?case=15150", // URL to retrieve resources related to this case.
      "...": "..."
    },
    ...
    // More cases here
  ]
}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://api.clearinghouse.net/api-reference-v2/new-features/pagination.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
