> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fetchski-attract.com/llms.txt
> Use this file to discover all available pages before exploring further.

# List pages, then get each one

> One HTTP Request node lists your pages' ids, Split Out makes each page its own item, and a second HTTP Request node gets every page by its id.

> [card]
>
> ![n8n](https://mintlify.s3.us-west-1.amazonaws.com/fetchski-attract-api/logo/n8n.png)
>
> ![Fetchski Attract](https://mintlify.s3.us-west-1.amazonaws.com/fetchski-attract-api/logo/attract-glyph-ball-green-on-light-scalable.svg)
>
> ![Fetchski Attract](https://mintlify.s3.us-west-1.amazonaws.com/fetchski-attract-api/logo/attract-glyph-ball-green-on-dark-scalable.svg)
>
> Coming soon: the Fetchski Attract node for n8n
>
> A full community node for the Attract API: every call a ready-made action, with your key and its
> signing handled for you. Until it ships, n8n's **HTTP Request** node reaches the whole API, as
> this page shows.

Most calls name one document by its `_id`: get a page, change it, publish it. To reach every page,
chain three nodes:

Trigger

any trigger

List your pages

HTTP Request

One item per page

Split Out

Get each page

HTTP Request, runs 3 times

The numbers are what n8n shows on each connector after a run, here on a site with three pages.

> [card] 1. List
>
> One request answers every page's `_id`, in a single item.

> [card] 2. Split
>
> **Split Out** turns that one item into one item per page.

> [card] 3. Get each
>
> n8n runs the next node once per item, with that page's `_id`.

> [!NOTE]
>
> Set up your key first in [Authenticate from n8n](https://docs.fetchski-attract.com/recipes/n8n-authenticate.md). It needs **Pages: read**
> (`content:pages:read`): pick the **Read pages** pack. The steps below use a token only key;
> [With a signed key](#with-a-signed-key) shows what changes.

## Build it

**1. List your pages**

Add an **HTTP Request** node after your trigger, with this **URL**:

```text URL wrap theme={"dark"}
https://acme.example/api/v1/@apostrophecms/page?all=1&flat=1&fields=title,slug
```

| Setting | Value |
| - | - |
| **Method** | `GET` |
| **Authentication** | `Generic Credential Type` |
| **Generic Auth Type** | `Header Auth` |
| **Header Auth** | `Fetchski Attract key` |

`all=1` (Every page, not only the top of the tree) asks for every page,
`flat=1` (One list, not nested children) in one flat list, and
`fields=title,slug` (Only these fields, plus \_id) keeps each one small.
Click **Execute step**. The answer is **one item** holding a `results` list:

```json Output: 1 item theme={"dark"}
{
  "results": [
    { "_id": "ckq3v8x5b0001:en:published", "title": "Home", "slug": "/" },
    { "_id": "ckq3v8x5b0002:en:published", "title": "About Us", "slug": "/about-us" },
    { "_id": "ckq3v8x5b0003:en:published", "title": "Pricing", "slug": "/pricing" }
  ]
}
```

A node after this one would run **once**, not once per page. The next step fixes that.

![n8n's HTTP Request node listing pages, its output one item with a results list](https://mintcdn.com/fetchski-attract-api/mn9qfQRsqaASh7UE/images/n8n/list-your-pages.png?fit=max\&auto=format\&n=mn9qfQRsqaASh7UE\&q=85\&s=a530f06907ea35a3d6ba2af88768991a)

List your pages: one item, holding results

**2. Split the results into items**

Add a **Split Out** node:

| Setting | Value |
| - | - |
| **Fields To Split Out** | `results` |
| **Include** | `No Other Fields` |

Click **Execute step**. Each page is now its own item, with `_id` at the top:

```json Output: 3 items theme={"dark"}
[
  { "_id": "ckq3v8x5b0001:en:published", "title": "Home", "slug": "/" },
  { "_id": "ckq3v8x5b0002:en:published", "title": "About Us", "slug": "/about-us" },
  { "_id": "ckq3v8x5b0003:en:published", "title": "Pricing", "slug": "/pricing" }
]
```

![n8n's Split Out node splitting results, its output one item per page](https://mintcdn.com/fetchski-attract-api/mn9qfQRsqaASh7UE/images/n8n/split-out.png?fit=max\&auto=format\&n=mn9qfQRsqaASh7UE\&q=85\&s=039f7c19a5a9720024b8adf7f3c046c6)

One item per page

> [!TIP]
>
> Want only some pages? Put a **Filter** node here, on any field you asked for in `fields`, e.g.
> `{{ $json.slug }}` **starts with** `/services`.

**3. Get each page by its id**

Add a second **HTTP Request** node, with this **URL**:

```text URL wrap theme={"dark"}
https://acme.example/api/v1/@apostrophecms/page/{{ $json._id }}
```

| Setting | Value |
| - | - |
| **Method** | `GET` |
| **Authentication** | `Generic Credential Type` |
| **Generic Auth Type** | `Header Auth` |
| **Header Auth** | `Fetchski Attract key` |

To write `{{ $json._id }}`, drag `_id` from the input panel on the left into the end of the
URL. n8n runs the node once per item, and `{{ $json._id }}` is that item's id each time.

![n8n's HTTP Request node with the page's \_id in its URL and the split items in its input panel](https://mintcdn.com/fetchski-attract-api/mn9qfQRsqaASh7UE/images/n8n/get-each-page.png?fit=max\&auto=format\&n=mn9qfQRsqaASh7UE\&q=85\&s=155f50a706b39a01ac0592cb8332da40)

Get each page: the \_id dragged into the URL

**4. Run the workflow**

Click **Execute workflow**.

**You should see** `1 item` on the connector out of **List your pages**, and one item per page
out of **One item per page** and **Get each page**: each of those last items is a whole page,
every field and section included.

![The n8n canvas after a run, with item counts on each connector](https://mintcdn.com/fetchski-attract-api/mn9qfQRsqaASh7UE/images/n8n/list-then-get-canvas.png?fit=max\&auto=format\&n=mn9qfQRsqaASh7UE\&q=85\&s=1a6c77dc5ed619a0419ebc3b653e12d2)

After a run: 1 item into Split Out, 3 items out of it, and Get each page called once for each

## With a signed key

> [tab] Token + signature on writes
>
> Nothing changes. This chain only reads, and this key signs only its writes, so the token alone
> does it.

> [tab] Token + signature on every request
>
> Reads are signed too, so each HTTP Request node gets **What to sign** and **Sign it** from
> [Authenticate from n8n](https://docs.fetchski-attract.com/recipes/n8n-authenticate.md#token-and-hmac-signature) just before it:
>
> What to sign
>
> path: the list
>
> Sign it
>
> Crypto
>
> List your pages
>
> HTTP Request
>
> One item per page
>
> Split Out
>
> First the list: signed once.
>
> One item per page
>
> Split Out
>
> What to sign
>
> path: each page
>
> Sign it
>
> Crypto
>
> Get each page
>
> HTTP Request
>
> Then each page: signed once per item.
>
> The second **What to sign** runs once per page, and builds that page's path from its id, so each
> page gets its own signature:
>
> | Name | Type | Value |
> | - | - | - |
> | `timestamp` | Number | `{{ $now.toUnixInteger() }}` |
> | `method` | String | `GET` |
> | `path` | String | `/api/v1/@apostrophecms/page/{{ $json._id }}` |
> | `body` | String | Empty |
>
> **Get each page** then takes its URL from that path, `https://acme.example{{ $json.path }}`, and
> sends the two signature headers.

## Going further

> [accordion] Change each page instead of reading it
>
> Swap the last node's method for `PATCH`, add `?aposMode=draft` to its URL so only the draft
> changes, and send the change as its body. The key needs **Pages: write drafts**
> (`content:pages:write`). On a key that signs writes, put the body in **What to sign** and send
> it **Raw**, as in [Signing a write](https://docs.fetchski-attract.com/recipes/n8n-authenticate.md#build-it-in-n8n).
> [Drafts and locales](https://docs.fetchski-attract.com/drafts-and-locales.md) explains the modes.

> [accordion] Other content types
>
> Every piece type lists at `GET /api/v1/<type>` with the same `fields`, and answers one document
> at `GET /api/v1/<type>/{_id}`. A piece list comes a page of results at a time: add
> `perPage=100` and walk `page` (the HTTP Request node's **Options** → **Pagination** can do it).
> [Find a document's id](https://docs.fetchski-attract.com/find-an-id.md) has the details.

> [accordion] Many pages at once
>
> A key allows 600 reads and 120 writes a minute unless set otherwise. Over it, n8n says "The
> service is receiving too many requests from you": on **Get each page** open **Options** →
> **Batching** and send fewer items a minute.

## Related

> [card] [Authenticate from n8n](https://docs.fetchski-attract.com/recipes/n8n-authenticate.md)
>
> Token only, or token and HMAC signature

> [card] [Find a document's id](https://docs.fetchski-attract.com/find-an-id.md)
>
> The `fields` parameter, and which id to send

> [card] [List pages](https://docs.fetchski-attract.com/api-reference/pages/list-pages.md)
>
> The route, its parameters and its answer

> [card] [Required scopes](https://docs.fetchski-attract.com/scopes.md)
>
> Every operation's scope, per content type


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.