| name | firecrawl-sdk-patterns |
| description | Apply production-ready Firecrawl SDK patterns for TypeScript and Python.
Use when implementing Firecrawl integrations, building reusable scraping services,
or establishing team coding standards for Firecrawl.
Trigger with phrases like "firecrawl SDK patterns", "firecrawl best practices",
"firecrawl code patterns", "idiomatic firecrawl", "firecrawl wrapper".
|
| allowed-tools | Read, Write, Edit |
| version | 1.11.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","firecrawl","python","typescript"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Firecrawl SDK Patterns
Overview
Production-ready patterns for Firecrawl SDK (@mendable/firecrawl-js / firecrawl-py). Covers singleton client, typed wrappers, retry with backoff, response validation, and reusable scraping service patterns.
Prerequisites
@mendable/firecrawl-js installed
- Understanding of async/await patterns
- TypeScript strict mode recommended
Instructions
Step 1: Singleton Client with Configuration
import FirecrawlApp from "@mendable/firecrawl-js";
let instance: FirecrawlApp | null = null;
export function getFirecrawl(): FirecrawlApp {
if (!instance) {
if (!process.env.FIRECRAWL_API_KEY) {
throw new Error("FIRECRAWL_API_KEY environment variable is required");
}
instance = new FirecrawlApp({
apiKey: process.env.FIRECRAWL_API_KEY,
...(process.env.FIRECRAWL_API_URL
? { apiUrl: process.env.FIRECRAWL_API_URL }
: {}),
});
}
return instance;
}
Step 2: Typed Scrape Wrapper
import { getFirecrawl } ;
{
: ;
: ;
: ;
: [];
: ;
}
(): <> {
firecrawl = ();
: [] = [];
(options?.) formats.();
result = firecrawl.(url, {
formats,
: ,
...(options?. ? { : options. } : {}),
});
(!result.) {
();
}
{
: result.?. || url,
: result.?. || ,
: result. || ,
: result. || [],
: ().(),
};
}