apify-sdk-patterns
Installation
SKILL.md
Apify SDK Patterns
Overview
Production patterns for both the apify SDK (building Actors) and apify-client (calling Actors remotely). Covers Crawlee crawler selection, data storage, proxy configuration, and typed client wrappers. This skill gives you the essential skeletons inline; the full eight-pattern catalog and two worked scenarios live in references/ for progressive drill-down.
Prerequisites
- Install what you need:
apify-clientfor calling Actors remotely, orapify+crawleefor building Actors. Both can coexist in one project. - Set
APIFY_TOKENin the environment — read it viaprocess.env.APIFY_TOKEN, never hard-code it. This is the only credential these patterns require (Apify uses a personal API token, not OAuth). - TypeScript is recommended; every snippet here is typed and runs under
ts-nodeor a compiled build.
Instructions
Use the two skeletons below to start, then reach into the reference catalog for the pattern that matches your task.
Pattern 1: Typed Client Singleton
Create one lazily-initialized, token-validated ApifyClient and reuse it everywhere. A resetClient() hook keeps it testable.