$npx -y skills add apify/agent-skills --skill apify-actorizationConvert existing projects into Apify Actors - serverless cloud programs. Actorize JavaScript/TypeScript (SDK with Actor.init/exit), Python (async context manager), or any language (CLI wrapper). Use when migrating code to Apify, wrapping CLI tools as Actors, or adding Actor SDK t
| 1 | # Apify Actorization |
| 2 | |
| 3 | Actorization converts existing software into reusable serverless applications compatible with the Apify platform. Actors are programs packaged as Docker images that accept well-defined JSON input, perform an action, and optionally produce structured JSON output. |
| 4 | |
| 5 | ## Quick start |
| 6 | |
| 7 | 1. Run `apify init` in project root |
| 8 | 2. Wrap code with SDK lifecycle (see language-specific section below) |
| 9 | 3. Configure `.actor/input_schema.json` |
| 10 | 4. Test with `apify run --input '{"key": "value"}'` |
| 11 | 5. Deploy with `apify push` |
| 12 | |
| 13 | ## When to use this skill |
| 14 | |
| 15 | - Converting an existing project to run on the Apify platform |
| 16 | - Adding Apify SDK integration to a project |
| 17 | - Wrapping a CLI tool or script as an Actor |
| 18 | - Migrating a Crawlee project to Apify |
| 19 | |
| 20 | ## Prerequisites |
| 21 | |
| 22 | Verify `apify` CLI is installed: |
| 23 | |
| 24 | ```bash |
| 25 | apify --help |
| 26 | ``` |
| 27 | |
| 28 | If not installed, use one of these methods (listed in order of preference): |
| 29 | |
| 30 | ```bash |
| 31 | # Preferred: install via a package manager (provides integrity checks) |
| 32 | npm install -g apify-cli |
| 33 | |
| 34 | # Or (Mac): brew install apify-cli |
| 35 | ``` |
| 36 | |
| 37 | > **Security note:** Do NOT install the CLI by piping remote scripts to a shell |
| 38 | > (e.g. `curl ... | bash` or `irm ... | iex`). Always use a package manager. |
| 39 | |
| 40 | Verify CLI is logged in: |
| 41 | |
| 42 | ```bash |
| 43 | apify info # Should return your username |
| 44 | ``` |
| 45 | |
| 46 | If not logged in, authenticate using OAuth (opens browser): |
| 47 | |
| 48 | ```bash |
| 49 | apify login |
| 50 | ``` |
| 51 | |
| 52 | If browser login isn't available (headless environment or CI), ensure the `APIFY_TOKEN` environment variable is exported (note: the variable is `APIFY_TOKEN`, not `APIFY_API_TOKEN`). The CLI reads it automatically - no explicit login needed. If the user doesn't have a token, generate one at https://console.apify.com/settings/integrations. |
| 53 | |
| 54 | > **Apify platform environment:** When the Actor runs on the Apify platform, `APIFY_TOKEN` is auto-injected as an environment variable and the Apify SDK reads it automatically — you do not need to pass it explicitly. Locally, `apify login` stores credentials in `~/.apify` and the SDK uses them. |
| 55 | |
| 56 | > **Security note:** Avoid passing tokens as command-line arguments (e.g. `apify login -t <token>`). |
| 57 | > Arguments are visible in process listings and may be recorded in shell history. |
| 58 | > Prefer OAuth login or environment variables instead. |
| 59 | > Never log, print, or embed `APIFY_TOKEN` in source code or configuration files. |
| 60 | > Use a token with the minimum required permissions (scoped token) and rotate it periodically. |
| 61 | |
| 62 | ## Actorization checklist |
| 63 | |
| 64 | Copy this checklist to track progress: |
| 65 | |
| 66 | - [ ] Step 1: Analyze project (language, entry point, inputs, outputs) |
| 67 | - [ ] Step 2: Run `apify init` to create Actor structure |
| 68 | - [ ] Step 3: Apply language-specific SDK integration |
| 69 | - [ ] Step 4: Configure `.actor/input_schema.json` |
| 70 | - [ ] Step 5: Configure `.actor/output_schema.json` (if applicable) |
| 71 | - [ ] Step 6: Update `.actor/actor.json` metadata |
| 72 | - [ ] Step 7: Write README.md for Apify Store listing |
| 73 | - [ ] Step 8: Test locally with `apify run` |
| 74 | - [ ] Step 9: Deploy with `apify push` |
| 75 | |
| 76 | ## Step 1: Analyze the project |
| 77 | |
| 78 | Before making changes, understand the project: |
| 79 | |
| 80 | 1. **Identify the language** - JavaScript/TypeScript, Python, or other |
| 81 | 2. **Find the entry point** - The main file that starts execution |
| 82 | 3. **Identify inputs** - Command-line arguments, environment variables, config files |
| 83 | 4. **Identify outputs** - Files, console output, API responses |
| 84 | 5. **Check for state** - Does it need to persist data between runs? |
| 85 | |
| 86 | ## Step 2: Initialize Actor structure |
| 87 | |
| 88 | Run in the project root: |
| 89 | |
| 90 | ```bash |
| 91 | apify init |
| 92 | ``` |
| 93 | |
| 94 | This creates: |
| 95 | - `.actor/actor.json` - Actor configuration and metadata |
| 96 | - `.actor/input_schema.json` - Input definition for Apify Console |
| 97 | - `Dockerfile` (if not present) - Container image definition |
| 98 | |
| 99 | ## Step 3: Apply language-specific changes |
| 100 | |
| 101 | Choose based on your project's language: |
| 102 | |
| 103 | - **JavaScript/TypeScript**: See [js-ts-actorization.md](references/js-ts-actorization.md) |
| 104 | - **Python**: See [python-actorization.md](references/python-actorization.md) |
| 105 | - **Other Languages (CLI-based)**: See [cli-actorization.md](references/cli-actorization.md) |
| 106 | |
| 107 | ### Quick reference |
| 108 | |
| 109 | | Language | Install | Wrap Code | |
| 110 | |----------|---------|-----------| |
| 111 | | JS/TS | `npm install apify` | `await Actor.init()` ... `await Actor.exit()` | |
| 112 | | Python | `pip install apify` | `async with Actor:` | |
| 113 | | Other | Use CLI in wrapper script | `apify actor:get-input` / `apify actor:push-data` | |
| 114 | |
| 115 | ## Steps 4-6: Configure schemas |
| 116 | |
| 117 | See [schemas-and-output.md](references/schemas-and-output.md) for detailed configuration of: |
| 118 | - Input schema (`.actor/input_schema.json`) |
| 119 | - Output schema (`.actor/output_schema.json`) |
| 120 | - Actor configuration (`.actor/actor.json`) |
| 121 | - State management (re |