Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Limiting page size with
Limiting page size prevents overwhelming clients or servers when querying large datasets. In REST, Data API builder (DAB) uses the $first parameter to control how many records are returned in a single response. DAB applies cursor-based pagination internally, but $first can be used even when continuation isn't required.
Note
$first limits the number of rows returned but doesn't itself handle continuation. For multiple pages, use $after.
Go to the GraphQL version of this document.
Overview
| Concept | Description |
|---|---|
| Default page size | runtime.pagination.default-page-size (defaults to 100) |
| Max page size | runtime.pagination.max-page-size (defaults to 100000) |
| Client override | $first |
| Requesting max | $first=-1 requests the configured max page size |
If $first is omitted, the default page size applies automatically.
Usage pattern
GET /api/{entity}?$first=N
Example
Limit the results to five books.
GET /api/books?$first=5
Conceptual SQL
SELECT TOP (5)
id,
sku_title AS title
FROM dbo.books
ORDER BY id ASC;
Sample response
{
"value": [
{ "id": 1, "title": "Dune" },
{ "id": 2, "title": "Foundation" },
{ "id": 3, "title": "Hyperion" },
{ "id": 4, "title": "I, Robot" },
{ "id": 5, "title": "The Martian" }
]
}
Validation rules
| Input | Result |
|---|---|
| Omitted | Uses default-page-size |
| Positive integer ≤ max | Accepted |
-1 |
Expanded to max-page-size |
0 |
400 (invalid) |
< -1 |
400 |
> max-page-size |
400 |
Example error message
Invalid number of items requested, first argument must be either -1 or a positive number within the max page size limit of 100000. Actual value: 0
Example configuration
{
"runtime": {
"pagination": {
"default-page-size": 100,
"max-page-size": 100000
}
},
"entities": {
"Book": {
"source": {
"type": "table",
"object": "dbo.books"
},
"mappings": {
"sku_title": "title",
"sku_price": "price"
},
"relationships": {
"book_category": {
"cardinality": "one",
"target.entity": "Category",
"source.fields": [ "category_id" ],
"target.fields": [ "id" ]
}
}
},
"Category": {
"source": {
"type": "table",
"object": "dbo.categories"
},
"relationships": {
"category_books": {
"cardinality": "many",
"target.entity": "Book",
"source.fields": [ "id" ],
"target.fields": [ "category_id" ]
}
}
}
}
}
See also
| Concept | REST | GraphQL | Purpose |
|---|---|---|---|
| Projection | $select | items | Choose which fields to return |
| Filtering | $filter | filter | Restrict rows by condition |
| Sorting | $orderby | orderBy | Define the sort order |
| Page size | $first | first | Limit the number of items per page |
| Continuation | $after | after | Continue from the last page using a cursor |
Note
REST keywords begin with $, following OData conventions.