apify-sdk-patterns

Featured

Production-ready patterns for Apify SDK and apify-client in TypeScript. Use when building Actors with Crawlee, managing datasets/KV stores, or implementing robust client wrappers with retry and validation. Trigger: "apify SDK patterns", "apify best practices", "apify client wrapper", "crawlee patterns", "idiomatic apify".

AI & Automation 2,926 stars 433 forks Updated yesterday MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# 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. ## Prerequisites - `apify-client` and/or `apify` + `crawlee` installed - `APIFY_TOKEN` configured - TypeScript recommended ## Pattern 1: Typed Client Singleton ```typescript // src/apify/client.ts import { ApifyClient } from 'apify-client'; let instance: ApifyClient | null = null; export function getApifyClient(): ApifyClient { if (!instance) { const token = process.env.APIFY_TOKEN; if (!token) throw new Error('APIFY_TOKEN is required'); instance = new ApifyClient({ token }); } return instance; } // Reset for testing export function resetClient(): void { instance = null; } ``` ## Pattern 2: Crawlee Crawler Selection Choose the right crawler for the job: ```typescript import { CheerioCrawler, PlaywrightCrawler, PuppeteerCrawler } from 'crawlee'; // CHEERIO — Fast, lightweight, no JavaScript rendering // Use for: static HTML, server-rendered pages, APIs const cheerioCrawler = new CheerioCrawler({ async requestHandler({ request, $, enqueueLinks }) { const title = $('title').text(); await Actor.pushData({ url: request.url, title }); await enqueueLinks({ strategy: 'same-domain' }); }, }); // PLAYWRIGHT — Full browser, all engines, modern API // Use for: SPAs, JavaScript-heavy pages, complex interac...

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
1 years ago
Last Updated
yesterday
Language
Python
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category