KEEP LEARNING
Build the bigger picture.
The Workflow Engineer connects individual n8n concepts to testing, deployment and running a complete workflow.
Tips > Building Workflows
Many APIs that lack dedicated n8n nodes use cursor-based or offset-based pagination.
When an API has no dedicated n8n node, a single Code node can run the whole pagination loop. It calls the endpoint repeatedly -- following a cursor or incrementing an offset -- collects every page into one array, and returns all records as items. A page cap prevents infinite loops, and a short delay between requests respects rate limits.
Many APIs that lack dedicated n8n nodes use cursor-based or offset-based pagination. A Code node can handle the entire pagination loop, returning all pages as a single batch of items.
Real-world example: Fetching all records from a custom REST API that returns 100 items per page with a nextCursor field.
// Mode: Run Once for All Items
const baseUrl = 'https://api.example.com/v1/records';
const apiKey = $input.first().json.apiKey; // Or use credential expressions
const allRecords = [];
let cursor = null;
let page = 0;
const maxPages = 50; // Safety limit to prevent infinite loops
do {
const url = cursor
? `${baseUrl}?limit=100&cursor=${encodeURIComponent(cursor)}`
: `${baseUrl}?limit=100`;
const response = await this.helpers.httpRequest({
method: 'GET',
url,
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
});
if (response.data && Array.isArray(response.data)) {
allRecords.push(...response.data);
}
cursor = response.pagination?.nextCursor ?? null;
page++;
// Respect rate limits
if (cursor) {
await new Promise(resolve => setTimeout(resolve, 200));
}
} while (cursor && page < maxPages);
return allRecords.map(record => ({ json: record }));Tip: Use this.helpers.httpRequest. Inside Code nodes, this.helpers.httpRequest is the preferred way to make HTTP calls. It respects n8n's proxy settings and has built-in retry logic. Avoid fetch() or axios unless you have a specific reason.
Related: Use Edit Fields in "Map Each" Mode for Simple Renames · Configure Payload Size and Binary Data Mode for Large Files
KEEP LEARNING
The Workflow Engineer connects individual n8n concepts to testing, deployment and running a complete workflow.
APPLY IT TO YOUR SYSTEM
Bring the process, the tools involved and an example of where the current workflow gets stuck.