From 7e68a28c99291857c1df669fa55d2e28efb4415e Mon Sep 17 00:00:00 2001 From: Megan Steenkamp Date: Wed, 4 Oct 2023 10:58:32 +1100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Migrate=20Pagination=20Ref?= =?UTF-8?q?erence?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change to migrate pagination reference guide to the new site. Currently using guide styling while awaiting UI input. 📖 Migrate API Reference Guides: https://www.notion.so/centrapay/Migrate-API-Reference-Guides-13d91fa1f0a443c7b1d5c64aa353151c?pvs=4 Test plan: Expect to see in dev site draft mode. --- src/content/api/pagination.mdx | 90 ++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 src/content/api/pagination.mdx diff --git a/src/content/api/pagination.mdx b/src/content/api/pagination.mdx new file mode 100644 index 000000000..419c4259e --- /dev/null +++ b/src/content/api/pagination.mdx @@ -0,0 +1,90 @@ +--- +title: Pagination +description: Introduction to Pagination +draft: true +nav: + path: API + order: 5 +--- + +Pagination allows a listing endpoint to return a subset of results. The goal is to reduce memory +usage and speed up page rendering. + +To retrieve the next page, a `pageKey` can be supplied. Typically this will be the `nextPageKey` +returned from your previous query. + +Please note that when making a request, the values of `pageKey` must be URL-encoded. This ensures proper handling of special characters and encoding requirements. + +Some of our endpoints have been designed to be forwards compatible with pagination. When we do +bring support to GET endpoints for listing, these conventions will be followed. + +## Request + +### Optional Fields + +| Field | Type | Description | +| ------- | ------ | ---------------------------------------- | +| pageKey | String | Used to retrieve the next page of items. | + +### Example + +A GET endpoint for listing with a `pageKey`. + +```bash [Request] +curl -X GET https://service.centrapay.com/api/examples \ + -H "X-Api-Key: $api_key" \ + -d '{ + "pageKey": "Example#E9eXsErwA444qFDoZt5iLA|Activity#000000000000001|614161c4c4d3020073bd4ce8" + }' +``` + +## Response + +### Required Fields + +| Field | Type | Description | +| ----- | ----- | -------------------------------------- | +| items | Array | A list of items from the current page. | + +### Optional Fields + +| Field | Type | Description | +| ----------- | ------- | ----------------------------------------------------------------- | +| nextPageKey | String | Can be used to fetch the next page, not present on the last page. | + +### Example + +Example response with more content. + +```json [Response] +{ + "nextPageKey": "5ee0c486308f590260d9a07f|ded3f328-1123-11ec-bf1a-5ba46eb12a7d", + "items": [ + { + "value": "16", + "assetType": "centrapay.nzd.main" + }, + { + "value": "32", + "assetType": "centrapay.nzd.main" + }, + { + "value": "64", + "assetType": "centrapay.nzd.main" + } + ] +} +``` + +Example response with the final page. + +```json [Response] +{ + "items": [ + { + "value": "128", + "assetType": "centrapay.nzd.main" + } + ] +} +```