> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt ## Resource: About Sorting and Paging ## Article: About Sorting and Paging ## Article Link: https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-sorting-and-paging.md ## Article Content: # About Sorting and Paging List, query, and search methods that return a list of entities may allow you to specify sorting and paging options in the request. This article provides a general overview of sorting and paging. The implementation syntax varies between methods. Check your API's documentation for specific details, including which fields are sortable. ## Sorting Most APIs default to sorting by `createdDate` in `DESC` (descending) order, although some APIs have a different default sort order. You can often override the default sorting by specifying a new field and order. ### Sort list results List methods are designed to be lightweight requests. For this reason, sorting is applied in REST through query parameters, typically with `sort.fieldName` and `sort.order` fields. For example, to list contacts by last name in ascending order: ```txt ?sort.fieldName=info.name.last&sort.order=ASC ``` ### Sort query results Query methods offer more robust filtering capabilities. When working with a Query method, sorting is specified in an array in the request body, typically `query.sort`, and is typically applied with the `fieldName` and `order` parameters. For example, to list payment links by created date in ascending order, and by status in descending order: ```json { "query": { "sort": [ { "fieldName": "createdDate", "order": "ASC" }, { "fieldName": "status", "order": "DESC" } ] } } ``` ### Sort search results When working with a Search method, sorting is typically specified in the `search.sort` parameter. For example, to search payment links by created date in ascending order: ```json { "search": { "sort": [ { "fieldName": "createdDate", "order": "ASC" } ] } } ``` ## Paging Paging allows you to control how many results are returned and where the result set starts. Wix APIs commonly support 1 or both of the following paging strategies: - **Offset-based** (includes `limit` and `skip`/`offset`): Specify the number of items to skip and the number to return. - **Cursor-based** (includes `nextCursor` and `prevCursor`): Use a token (cursor) to fetch the next or previous set of results. ### Paging list results List methods support paging through query parameters in REST requests and `options` objects in SDK calls. For example, to list 100 contacts, starting from contact 21, with offset paging: ```txt ?limit=100&offset=20 ``` Should return items 21-120 in the results. For calls that support cursor paging, after receiving a cursor in your first request, list the next set of entities with cursor paging: ```txt &cursorPaging.cursor=JWE.eyJhbGciOiJBMTI4S1ciLCJlbm ``` ### Paging query results Query methods handle paging through the request body in REST and method parameters in the SDK. Generally either offset-based or cursor-based strategies are supported, and occasionally both are supported. For example, to query 100 contacts, starting from contact 21, with offset paging: ```json "query": { "paging": { "limit": 100, "offset": 20 } } ``` Should return items 21-120 in the results. To query 100 payment links with cursor paging: ```json "query": { "cursorPaging": { "cursor": "JWE.eyJhbGciOiJBMTI4S1ciLCJlbm" } } ``` ### Paging search results When working with a Search method, paging is typically specified in the paging or cursorPaging parameter. Search methods typically use cursor-based paging to ensure consistent results even when the underlying data changes during pagination. For example, to search for 10 payment links, and return a cursor for paging: ```json "search": { "cursorPaging": { "limit": 10 } } ``` Should return 10 items. To retrieve the next 10 payment links with a cursor: ```json "search": { "cursorPaging": { "cursor": "JWE.eyJhbGciOiJBMTI4S1ciLCJlbm" } ```