From 055548f57e4085fdd8e9b60fb40a83caee58d9b0 Mon Sep 17 00:00:00 2001 From: Mariana Date: Wed, 8 May 2024 15:08:57 +0100 Subject: [PATCH 1/3] pagination examples update --- docs/code/cookbook/http-node/pagination.md | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/docs/code/cookbook/http-node/pagination.md b/docs/code/cookbook/http-node/pagination.md index 3100292e1..5b21163a7 100644 --- a/docs/code/cookbook/http-node/pagination.md +++ b/docs/code/cookbook/http-node/pagination.md @@ -11,9 +11,6 @@ Refer to [HTTP Request](/integrations/builtin/core-nodes/n8n-nodes-base.httprequ --8<-- "_snippets/integrations/builtin/core-nodes/http/pagination-api-differences.md" -## An example API - -You can try these examples with any API that supports pagination. If you need a free option, [Punk API](https://punkapi.com/documentation/v2){:target=_blank .external-link} is free with rate limits, and doesn't require authorization. ## Enable pagination @@ -35,19 +32,29 @@ If the API you're using allows you to target a particular page by number: 1. Set **Pagination Mode** to **Update a Parameter in Each Request**. 1. Set **Type** to **Query**. -1. Enter the **Name** of the query parameter. This depends on your API. For example, Punk API uses a query parameter named `page` to set the page. So **Name** would be `page`. +1. Enter the **Name** of the query parameter. This depends on your API and is usually described in its documentation. For example, some APIs use a query parameter named `page` to set the page. So **Name** would be `page`. 1. Hover over **Value** and toggle **Expression** on. 1. Enter `{{ $pageCount + 1 }}` `$pageCount` is the number of pages the HTTP Request node has fetched. It starts at zero. Most API pagination counts from one (the first page is page one). This means that adding `+1` to `$pageCount` means the node fetches page one on its first loop, page two on its second, and so on. +## Navigate pagination through body parameters + +If the API you're using allows you to paginate throught the body parameters: + +1. Set the HTTP Request Method to **POST** +1. Set **Pagination Mode** to **Update a Parameter in Each Request**. +1. Select **Body** in the **Type** parameter. +1. Enter the **Name** of the body parameter. This depends on the API you are using. `page` is a common key name. +1. Hover over **Value** and toggle **Expression** on. +1. Enter `{{ $pageCount + 1 }}` + ## Set the page size in the query If the API you're using supports choosing the page size in the query: -1. Select **Add Parameter** in **Query Parameters**. This is in the main node parameters, not in the option settings. -1. Enter the **Name** of the query parameter. This depends on your API. For example, Punk API uses a query parameter named `per_page` to set page size. So **Name** would be `per_page`. +1. Select **Send Query Parameters** in node parameters, not in the option settings. +1. Enter the **Name** of the query parameter. This depends on your API. For example, a lot of APIs use a query parameter named `limit` to set page size. So **Name** would be `limit`. 1. In **Value**, enter your page size. - From e36cadc1e84210f7084d55ca1b6b315f8f63a86c Mon Sep 17 00:00:00 2001 From: Mariana Date: Wed, 8 May 2024 15:25:12 +0100 Subject: [PATCH 2/3] orthographic mistake fix --- docs/code/cookbook/http-node/pagination.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/code/cookbook/http-node/pagination.md b/docs/code/cookbook/http-node/pagination.md index 5b21163a7..1b586d51f 100644 --- a/docs/code/cookbook/http-node/pagination.md +++ b/docs/code/cookbook/http-node/pagination.md @@ -40,7 +40,7 @@ If the API you're using allows you to target a particular page by number: ## Navigate pagination through body parameters -If the API you're using allows you to paginate throught the body parameters: +If the API you're using allows you to paginate through the body parameters: 1. Set the HTTP Request Method to **POST** 1. Set **Pagination Mode** to **Update a Parameter in Each Request**. From 0f5584042b6e0690796311666e74c3ee631ca40d Mon Sep 17 00:00:00 2001 From: Deborah Date: Wed, 8 May 2024 15:40:31 +0100 Subject: [PATCH 3/3] Apply suggestions from code review --- docs/code/cookbook/http-node/pagination.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/code/cookbook/http-node/pagination.md b/docs/code/cookbook/http-node/pagination.md index 1b586d51f..2ab331a79 100644 --- a/docs/code/cookbook/http-node/pagination.md +++ b/docs/code/cookbook/http-node/pagination.md @@ -45,7 +45,7 @@ If the API you're using allows you to paginate through the body parameters: 1. Set the HTTP Request Method to **POST** 1. Set **Pagination Mode** to **Update a Parameter in Each Request**. 1. Select **Body** in the **Type** parameter. -1. Enter the **Name** of the body parameter. This depends on the API you are using. `page` is a common key name. +1. Enter the **Name** of the body parameter. This depends on the API you're using. `page` is a common key name. 1. Hover over **Value** and toggle **Expression** on. 1. Enter `{{ $pageCount + 1 }}` @@ -53,7 +53,7 @@ If the API you're using allows you to paginate through the body parameters: If the API you're using supports choosing the page size in the query: -1. Select **Send Query Parameters** in node parameters, not in the option settings. +1. Select **Send Query Parameters** in main node parameters (this is the parameters you see when you first open the node, not the settings within options). 1. Enter the **Name** of the query parameter. This depends on your API. For example, a lot of APIs use a query parameter named `limit` to set page size. So **Name** would be `limit`. 1. In **Value**, enter your page size.