◆ STEPS
- 01Works in Node 18+, Bun, Deno, Cloudflare Workers.
- 02Full TypeScript types coming in the npm package.
◆ CODE · TYPESCRIPT
// Node 18+ — native fetch
export class FundedAPI {
private base = "https://fundedapi.com";
constructor(private key = process.env.FUNDED_API_KEY!) {}
private async req<T>(method: string, path: string, body?: unknown): Promise<T> {
for (let attempt = 0; attempt < 3; attempt++) {
const res = await fetch(this.base + path, {
method,
headers: {
Authorization: `Bearer ${this.key}`,
"Content-Type": "application/json",
},
body: body ? JSON.stringify(body) : undefined,
});
if (res.status === 429) {
const reset = Number(res.headers.get("X-RateLimit-Reset")) || Date.now() / 1000 + 60;
await new Promise((r) => setTimeout(r, Math.max(1000, (reset - Date.now() / 1000) * 1000)));
continue;
}
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);
return res.json() as Promise<T>;
}
throw new Error("max retries exceeded");
}
search(params: Record<string, string | number | boolean>) {
const qs = new URLSearchParams(
Object.entries(params).map(([k, v]) => [k, String(v)])
);
return this.req<{ startups: unknown[] }>("GET", `/v1/startups?${qs}`);
}
aiSearch(query: string) {
return this.req<{ startups: unknown[]; rationale: string }>(
"POST", "/v1/search/ai", { query }
);
}
}◆ PREREQUISITES
- ▸A FundedAPI key (free). Grab one.
- ▸Set
FUNDED_API_KEYin your environment. - ▸Read the API reference if you need other endpoints.
▶ RELATED RECIPES