TypeScript SDK
The @fomodata/sdk package: install, configure, use.
@fomodata/sdk is the TypeScript-first client for FomoData. Response types are generated from the OpenAPI document; the ergonomic wrapper on top is handcrafted. It runs anywhere fetch and WebCrypto do: Node 20+, Bun, Deno and edge runtimes.
Install
npm install https://fomodata.dev/sdk/fomodata-sdk-0.1.0.tgzThe npm package is coming soon. The tarball above is the exact package build, served by this deployment. Pin it in package.json like any other dependency.
Configure
import { FomoData } from "@fomodata/sdk";
export const fomo = new FomoData({ apiKey: process.env.FOMODATA_API_KEY });The client talks to https://fomodata.dev/v1 by default. Pass baseUrl (or set FOMODATA_API_BASE_URL, including /v1) only for a self-hosted or local API. Receiving webhooks (handle, constructEvent) needs only webhookSecret. Other options: streamUrl (or FOMODATA_STREAM_URL; otherwise the SDK discovers the active stream service from the API), timeoutMs (30 s), maxRetries (2), fetch, WebSocket, headers.
Keep keys server-side
Use live keys only on servers. Never ship a key in browser bundles or mobile apps.
Modules
| Module | What it covers | Docs |
|---|---|---|
fomo.profiles | get(ref), list({ id | handle | fomo_user_id }) / lookup(…) (both return one Profile) | Profiles |
fomo.theses | list(filters), iterate(filters), get(id), verify(input), createTest(input) | Theses |
fomo.tokens | get(ref), activity(ref), velocity(ref) | Tokens |
fomo.search | query(q, { types, limit }) | Search |
fomo.events | list(params), iterate(params), get(id) | Events |
fomo.webhooks | create, list, update, delete, rotateSecret, test, deliveries, replay; receiving: constructEvent and verifySignature (both async, WebCrypto), on(type, handler), handle(request) | Webhooks |
fomo.streams | subscribe(options) with auto-reconnect and cursor resume (fromCursor, subscription.cursor); reconnects after 1013 / 1001 with from_cursor | Streams |
Examples
Profile
const profile =
await fomo.profiles.get("@milo");Theses
const theses =
await fomo.theses.list({
token: "$RUN",
since: "1h"
});Verify
const result =
await fomo.theses.verify({
handle: "@milo",
token: "$RUN",
after: start,
before: end
});Stream
fomo.streams.subscribe({
event: "thesis.created",
token: "$RUN",
onEvent(event) {
console.log(event);
}
});Errors
Non-2xx responses throw a FomoDataError carrying the API's code, HTTP status and requestId. Codes are listed on the errors page.
import { FomoDataError } from "@fomodata/sdk";
try {
await fomo.profiles.get("@sbx_nobody");
} catch (err) {
if (err instanceof FomoDataError && err.code === "PROFILE_NOT_FOUND") {
// show "unknown handle"
} else {
throw err;
}
}GET requests and verifications are retried on 429, 5xx and network errors (twice by default, set maxRetries), honouring Retry-After. Other errors are thrown immediately. fomo.lastRequestId and fomo.rateLimit expose the latest request id and X-RateLimit-* values.
Other languages and tools
| Tool | Status |
|---|---|
| TypeScript / JavaScript | Available |
| Python | Coming soon |
| Go | Coming soon |
npx fomodata login · keys create · listen thesis.created | Coming soon |
Until then, any HTTP client works: the API reference shows curl for every endpoint, and the OpenAPI document at https://fomodata.dev/openapi.json can generate clients in other languages.