Skip to content
Skillv1.0.0

apify-hello-world

Run your first Apify Actor and retrieve results via apify-client. Use when starting a new Apify integration, testing connectivity, or learning the Actor call/dataset retrieval pattern. Trigger with "a

by jeremylongshore(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from jeremylongshore/tons-of-skills-marketplace (skills/.curated/apify-hello-world/SKILL.md). Install upstream with npx skills add jeremylongshore/tons-of-skills-marketplace --skill apify-hello-world. Copyright stays with the author (MIT).

Apify Hello World

Overview

Run a public Actor from the Apify Store, wait for it to finish, and retrieve the scraped data. This demonstrates the fundamental call-wait-collect pattern used in every Apify integration.

Prerequisites

  • npm install apify-client completed
  • APIFY_TOKEN environment variable set
  • See apify-install-auth if not ready

Authentication

Every call authenticates with a personal API token passed to the client constructor: new ApifyClient({ token: process.env.APIFY_TOKEN }). Keep the token in the APIFY_TOKEN environment variable — never hard-code it in the script. Full setup (where to generate the token, how to export it) lives in the apify-install-auth skill.

Core Pattern: Call Actor, Get Data

import { ApifyClient } from 'apify-client';

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

// 1. Run an Actor and wait for it to finish
const run = await client.actor('apify/website-content-crawler').call({
  startUrls: [{ url: 'https://docs.apify.com/academy' }],
  maxCrawlPages: 5,
});

// 2. Retrieve results from the default dataset
const { items } = await client.dataset(run.defaultDatasetId).listItems();

console.log(`Crawled ${items.length} pages:`);
items.forEach(item => {
  console.log(`  - ${item.url}: ${item.text?.substring(0, 80)}...`);
});

This is the whole workflow at a high level: authenticate, .call() an Actor, then read its default dataset. For sync-vs-async execution, pagination, downloads, key-value store retrieval, run-configuration options, and a table of popular starter Actors, see run & retrieval patterns.

Instructions

Step 1: Create the Script

Use Write (or Edit an existing file) to create hello-apify.ts (or .js) with the Core Pattern code above. Use Read to confirm the file contents before running.

Step 2: Run It

# With tsx (recommended)
npx tsx hello-apify.ts

# Or with Node.js (plain JS)
node hello-apify.js

Step 3: Understand the Output

The Actor runs on Apify's cloud infrastructure. See the Output section below for the run-object fields returned when it finishes.

Output

A successful run returns a run object plus a populated dataset. The fields you read most:

Field Meaning
run.id Unique run identifier
run.status SUCCEEDED, FAILED, TIMED-OUT, or ABORTED
run.defaultDatasetId ID of the dataset containing scrape results
run.defaultKeyValueStoreId ID of the KV store with metadata/artifacts
run.statusMessage Human-readable detail (essential when status is not SUCCEEDED)

client.dataset(run.defaultDatasetId).listItems() returns { items }, where each item is one scraped record (shape depends on the Actor). Always branch on run.status before reading the dataset — a FAILED run can leave an empty or partial dataset. See worked examples for the full run-object breakdown.

Error Handling

Error Cause Solution
Actor not found Wrong Actor ID Check ID at apify.com/store
run.status === 'FAILED' Actor crashed Check run.statusMessage for details
run.status === 'TIMED-OUT' Exceeded timeout Increase timeout or reduce workload
Dataset is empty Actor produced no output Verify input parameters; check Actor logs
402 Payment Required Insufficient compute units — Apify returns HTTP 402 when your account is out of prepaid units Top up at console.apify.com/billing

Examples

Minimal happy-path collection — call an Actor and count the results:

const run = await client.actor('apify/website-content-crawler').call({
  startUrls: [{ url: 'https://example.com' }],
  maxCrawlPages: 10,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(`Scraped ${items.length} pages`);

For the complete status-guarded "scrape and save to JSON" script and a full breakdown of the run object, see worked examples.

Resources

Next Steps

Once your first Actor run succeeds, proceed to the apify-local-dev-loop skill to build and iterate on your own Actor locally, then deploy it back to the Apify platform. That skill covers the develop-run-debug cycle in depth.

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/jeremylongshore-tons-of-skills-marketplace-apify-hello-world/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

jeremylongshore-tons-of-skills-marketplace-apify-hello-world.ocm.jsonjson
{
  "ocm": "1",
  "id": "jeremylongshore-tons-of-skills-marketplace-apify-hello-world",
  "kind": "skill",
  "name": "apify-hello-world",
  "description": "Run your first Apify Actor and retrieve results via apify-client. Use when starting a new Apify integration, testing connectivity, or learning the Actor call/dataset retrieval pattern. Trigger with \"apify hello world\", \"apify example\", \"run an apify actor\", \"apify quick start\", \"first apify scrape\".",
  "publisher": "jeremylongshore",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "general_chat",
      "data_analysis"
    ],
    "tags": [
      "skill-md",
      "saas",
      "scraping",
      "automation",
      "apify",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Run your first Apify Actor and retrieve results via apify-client. Use when starting a new Apify integration, testing connectivity, or learning the Actor call/dataset retrieval pattern. Trigger with \"apify hello world\", \"apify example\", \"run an apify actor\", \"apify quick start\", \"first apify scrape\"."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/jeremylongshore/tons-of-skills-marketplace",
      "path": "skills/.curated/apify-hello-world/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/jeremylongshore/tons-of-skills-marketplace/blob/HEAD/skills/.curated/apify-hello-world/SKILL.md",
      "key": "jeremylongshore/tons-of-skills-marketplace/skills/.curated/apify-hello-world/SKILL.md"
    },
    "compatibility": "Designed for Claude Code",
    "allowed_tools": [
      "Read,",
      "Write,",
      "Edit,",
      "Bash(npm:*),",
      "Bash(npx:*),",
      "Bash(node:*)"
    ],
    "license": "MIT"
  },
  "instructions": "# Apify Hello World\n\n## Overview\n\nRun a public Actor from the Apify Store, wait for it to finish, and retrieve the scraped data. This demonstrates the fundamental call-wait-collect pattern used in every Apify integration.\n\n## Prerequisites\n\n- `npm install apify-client` completed\n- `APIFY_TOKEN` environment variable set\n- See `apify-install-auth` if not ready\n\n## Authentication\n\nEvery call authenticates with a personal API token passed to the client\nconstructor: `new ApifyClient({ token: process.env.APIFY_TOKEN })`. Keep the\ntoken in the `APIFY_TOKEN` environment variable — never hard-code it i",
  "cost": {
    "context_tokens": 1191
  }
}

Fetch it by URL: GET /api/v1/registry/jeremylongshore-tons-of-skills-marketplace-apify-hello-world/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.