Skip to content

API 分页#

¥API pagination

默认页面大小为 100 条结果。你可以更改页面大小限制。允许的最大大小为 250。

¥The default page size is 100 results. You can change the page size limit. The maximum permitted size is 250.

当响应包含多个页面时,会包含一个游标,你可以使用该游标请求后续页面。

¥When a response contains more than one page, it includes a cursor, which you can use to request the next pages.

例如,假设你想要获取所有活动工作流,每次获取 150 个。

¥For example, say you want to get all active workflows, 150 at a time.

获取首页

¥Get the first page:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# For a self-hosted n8n instance
curl -X 'GET' \
  '<N8N_HOST>:<N8N_PORT>/<N8N_PATH>/api/v<version-number>/workflows?active=true&limit=150' \
  -H 'accept: application/json' \
  -H 'X-N8N-API-KEY: <your-api-key>'

# For n8n Cloud
curl -X 'GET' \
  '<your-cloud-instance>/api/v<version-number>/workflows?active=true&limit=150' \
  -H 'accept: application/json' \
  -H 'X-N8N-API-KEY: <your-api-key>'

响应采用 JSON 格式,并包含一个 nextCursor 值。这是一个响应示例。

¥The response is in JSON format, and includes a nextCursor value. This is an example response.

1
2
3
4
5
6
7
8
9
{
  "data": [
    // The response contains an object for each workflow
    {
      // Workflow data
    }
  ],
  "nextCursor": "MTIzZTQ1NjctZTg5Yi0xMmQzLWE0NTYtNDI2NjE0MTc0MDA"
}

然后请求下一页:

¥Then to request the next page:

1
2
3
4
5
6
7
8
9
# For a self-hosted n8n instance
curl -X 'GET' \
  '<N8N_HOST>:<N8N_PORT>/<N8N_PATH>/api/v<version-number>/workflows?active=true&limit=150&cursor=MTIzZTQ1NjctZTg5Yi0xMmQzLWE0NTYtNDI2NjE0MTc0MDA' \
  -H 'accept: application/json'

# For n8n Cloud
curl -X 'GET' \
  '<your-cloud-instance>/api/v<version-number>/workflows?active=true&limit=150&cursor=MTIzZTQ1NjctZTg5Yi0xMmQzLWE0NTYtNDI2NjE0MTc0MDA' \
  -H 'accept: application/json'