---
name: apify-deploy-integration
description: 'Deploy Apify Actors and integrate scraping into external applications.

  Use when deploying an Actor to the platform, integrating Actor results into a web app (Next.js, Express), wiring webhooks, or scheduling scraping pipelines.

  Trigger with "deploy apify actor", "apify Vercel integration", "apify production deploy", "integrate apify results", "apify API endpoint".'
allowed-tools: Read, Write, Edit, Bash(apify:*), Bash(npm:*), Bash(vercel:*), Bash(gcloud:*)
version: 1.5.0
license: MIT
author: Jeremy Longshore <jeremy@intentsolutions.io>
tags:
  - saas
  - scraping
  - automation
  - apify
compatibility: Designed for Claude Code
title: apify-deploy-integration
canonical_url: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/apify-deploy-integration
last_updated: 2026-10-07T06:06:28.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [references/examples.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/apify-deploy-integration/references/examples.md), [references/implementation.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/apify-deploy-integration/references/implementation.md).
>
> If the user asked to install this Skill, run `npx skilld install jeremylongshore/tons-of-skills-marketplace/apify-deploy-integration`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/apify-deploy-integration`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/jeremylongshore/tons-of-skills-marketplace/apify-deploy-integration) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/apify-deploy-integration`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/apify-deploy-integration --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/apify-deploy-integration --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Apify Deploy Integration

## Overview

Deploy Actors to the Apify platform and integrate their results into external
applications. Covers `apify push` deployment, API-triggered runs from web apps
(synchronous and async patterns), webhook receivers, scheduled scraping pipelines,
and container deployment.

SKILL.md gives you the workflow and the core skeleton. Complete, copy-paste code
for every pattern lives in [references/implementation.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/apify-deploy-integration/references/implementation.md);
end-to-end worked scenarios are in [references/examples.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/apify-deploy-integration/references/examples.md).

## Prerequisites

- Actor tested locally (`apify run`)
- `apify login` completed (stores CLI credentials)
- Target application ready for integration

## Authentication

Apps authenticate with an Apify API token. Generate one in **Apify Console →
Settings → Integrations** and expose it as the `APIFY_TOKEN` environment variable —
never hard-code it. The `apify` CLI uses its own credentials from `apify login`,
separate from `APIFY_TOKEN`. Full auth notes: [references/implementation.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/apify-deploy-integration/references/implementation.md).

## Instructions

### Step 1: Deploy the Actor to the platform

```bash
# Push Actor code to Apify
apify push

# Push to a specific Actor (creates if it doesn't exist)
apify push username/my-scraper

# Pull an existing Actor to modify
apify pull username/existing-actor
```

### Step 2: Trigger the Actor from your app

Instantiate `ApifyClient` with your token, then either `call()` (blocks until the
run finishes) or `start()` (returns immediately for polling). Here is the core
synchronous skeleton:

```typescript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: process.env.APIFY_TOKEN });

const run = await client.actor('username/product-scraper').call({
  startUrls: [{ url: 'https://store.example.com' }],
  maxItems: 500,
});
if (run.status !== 'SUCCEEDED') throw new Error(run.statusMessage);

const { items } = await client.dataset(run.defaultDatasetId).listItems();
```

The full typed service — `scrapeProducts` (blocking), `startScrape` +
`getScrapeResults` (async poll) — is in
[references/implementation.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/apify-deploy-integration/references/implementation.md).

### Step 3: Choose an integration pattern

Pick the pattern that matches your app, then copy the full handler from the
reference:

- **Next.js API route** — start a run in a `POST`, poll by run ID in a `GET`. Avoids
  serverless timeouts. See [implementation.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/apify-deploy-integration/references/implementation.md).
- **Express webhook receiver** — register an Apify webhook and react on
  `ACTOR.RUN.SUCCEEDED` / `FAILED` / `TIMED_OUT`. See [implementation.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/apify-deploy-integration/references/implementation.md).
- **Scheduled pipeline** — run on cron/Apify Schedule, export CSV, archive to a
  named dataset. See [implementation.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/apify-deploy-integration/references/implementation.md).
- **Docker / Cloud Run** — containerize an app that calls Apify, inject the token
  as a secret. See [implementation.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/apify-deploy-integration/references/implementation.md).

**Rule of thumb:** poll for request/response UX (a user waits on a result); use
webhooks for fire-and-forget pipelines (scheduled scrapes, background enrichment).

## Output

- A deployed Actor on the Apify platform (`apify push` build succeeds)
- An integration module (`src/services/apify.ts`) exposing blocking + async calls
- API routes / webhook receivers wired into your app's framework
- Structured results read from the Actor's default dataset (JSON or CSV export)
- Optional date-stamped archive in a named dataset for historical access

## Error Handling

| Issue | Cause | Solution |
|-------|-------|----------|
| `apify push` fails | Auth or build error | Check `apify login` and Dockerfile |
| Webhook not received | URL unreachable from internet | Use ngrok for dev; verify HTTPS in prod |
| Timeout in API route | Actor takes too long | Use async pattern (start + poll) |
| Memory error on platform | Actor needs more RAM | Increase `memory` option |
| Large dataset download | >100MB results | Use pagination or streaming |

## Examples

Three end-to-end scenarios — synchronous script call, non-blocking Next.js API,
and a scheduled CSV-export pipeline — are worked through in
[references/examples.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/apify-deploy-integration/references/examples.md). Minimal blocking call:

```typescript
import { scrapeProducts } from './services/apify';
const products = await scrapeProducts(['https://store.example.com/p/1']);
console.log(`Got ${products.length} products`);
```

## Resources

- [Actor Deployment](https://docs.apify.com/platform/actors/development/deployment)
- [API Integration Guide](https://docs.apify.com/platform/integrations/api)
- [Webhook Documentation](https://docs.apify.com/platform/integrations/webhooks)

## Next Steps

For webhook event handling in depth, see the `apify-webhooks-events` skill. For the
full integration code referenced above, see
[references/implementation.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/apify-deploy-integration/references/implementation.md).
