Apify + n8n Integration

Connect Apify to n8n for self-hosted automation workflows. Open-source alternative to Make.com and Zapier.

TL;DR

n8n is open-source workflow automation. Self-host for free or use n8n Cloud. Connect to Apify via HTTP Request node. Full control over data, no per-operation limits.

Why n8n with Apify?

n8n is the open-source alternative to Make.com and Zapier. Self-host it for unlimited workflows. Or use n8n Cloud for managed hosting.

Benefits over Make.com:

  • Self-host: No per-operation pricing
  • Open source: Customize anything
  • Data privacy: Your data stays on your server
  • Code nodes: Write JavaScript when needed

Setup Options

Option Cost Best For
n8n Cloud From $20/month Quick start, managed hosting
Self-hosted (Docker) Free + server costs Full control, data privacy
Desktop app Free Testing workflows locally

Connecting Apify to n8n

n8n does not have a native Apify node. Use the HTTP Request node to call Apify APIs.

Step 1: Get Your Apify API Token

  1. Log in to console.apify.com
  2. Go to Settings → Integrations
  3. Copy your Personal API Token

Step 2: Create Credentials in n8n

  1. Go to Settings → Credentials
  2. Add new Header Auth credential
  3. Name: Authorization
  4. Value: Bearer YOUR_API_TOKEN

Running an Actor

HTTP Request node to start an actor run:

// Method: POST
// URL: https://api.apify.com/v2/acts/USERNAME~ACTOR-NAME/runs

// Headers
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json

// Body
{
  "startUrls": ["https://example.com"],
  "maxItems": 100
}

Response includes the run ID for fetching results.

Fetching Results

After run completes, get dataset items:

// Method: GET
// URL: https://api.apify.com/v2/datasets/DATASET_ID/items

// Headers
Authorization: Bearer YOUR_API_TOKEN

Complete Workflow Example

Daily Google Maps scraping with email report:

  1. Schedule Trigger: Every day at 9am
  2. HTTP Request: POST to start Google Maps Scraper
  3. Wait: Delay 5 minutes for run to complete
  4. HTTP Request: GET dataset items
  5. Code Node: Format data as HTML table
  6. Gmail: Send email report

Code Node Example

// Format results as HTML table
const items = $input.all();

const tableRows = items.map(item =>
  `
    ${item.json.title}
    ${item.json.address}
    ${item.json.phone}
  `
).join('');

const html = `
  
    ${tableRows}
  
NameAddressPhone
`; return [{ json: { htmlReport: html } }];

Using Webhooks

Trigger n8n when Apify run completes:

  1. Create Webhook node in n8n. Copy the URL.
  2. In Apify Console, go to actor settings
  3. Add webhook: Run Finished → n8n webhook URL

n8n receives notification with run details. No polling needed.

Handling Errors

// Check run status before fetching results
// GET https://api.apify.com/v2/actor-runs/RUN_ID

// Check response.status
// SUCCEEDED = fetch results
// FAILED = handle error
// RUNNING = wait and retry

Common Questions

Q: Why no native Apify node?

A: n8n has 400+ nodes but Apify integration is not built-in yet. HTTP Request works perfectly. You can also contribute a community node.

Q: How do I handle long-running actors?

A: Use webhooks instead of polling. Or add a Wait node between starting and checking status.

Q: Can I run n8n on a $5 VPS?

A: Yes. n8n runs fine on small servers for personal use. Add more RAM for heavy workflows.

Q: n8n vs Make.com for Apify?

A: Make.com has native Apify module. Easier setup. n8n is better if you want self-hosting, unlimited operations, or custom code.