fetch API and store the API key as a Wrangler secret so it never touches your codebase.
Prerequisites
- Wrangler CLI installed (
pnpm add -g wrangler) - A Cloudflare account
- A Geekflare API key — get one free
Create a Worker
Set your API key
Store the key as a secret — never hardcode it:wrangler.toml so TypeScript knows it exists:
wrangler.toml
Env interface:
src/index.ts
Shared helper
A small typed helper keeps each handler clean:src/geekflare.ts
Web Scraping
src/index.ts
Search
Route requests to different Geekflare endpoints based on the URL path:src/index.ts
Screenshot
src/index.ts
Complete multi-route Worker
A single Worker handling all three endpoints:src/index.ts
Deploy
Error handling
| Code | Meaning |
|---|---|
401 | Missing or invalid x-api-key |
402 | API credits exhausted |
403 | Endpoint not available on your plan |
429 | Rate limit exceeded |
geekflarePost helper above throws on non-2xx responses. Wrap every handler in try/catch and map error codes to appropriate HTTP responses:
Next steps
- PHP quickstart — cURL and Guzzle
- API Reference — Full endpoint documentation
- SDK on npm