There is no published TypeScript SDK. The API is plain JSON over HTTPS, so fetch (in Node 18+, Deno, Bun, and browsers) is all you need. Keep API keys on a server: never ship one to a browser.
const API = "https://api.cognichem.com/api/v1";
const headers = { "X-Api-Key": process.env.COGNICHEM_API_KEY!, "Content-Type": "application/json" };
async function call<T>(path: string, init: RequestInit = {}): Promise<T> {
const response = await fetch(`${API}${path}`, { ...init, headers: { ...headers, ...init.headers } });
const body = await response.json();
if (!response.ok) {
// RFC 7807 problem detail: branch on status, type, and retryability.
throw Object.assign(new Error(`${body.status} ${body.detail}`), { problem: body });
}
return body as T;
}
// Price, then submit with an idempotency key.
const payload = { input_data: ["CCO", "c1ccccc1O"], input_format: "smiles" };
const estimate = await call<{ cost: number }>("/jobs/estimate", {
method: "POST",
body: JSON.stringify({ job_type: "padel-descriptor", payload }),
});
console.log(`Reserves $${estimate.cost.toFixed(4)}`);
const { process_id } = await call<{ process_id: string }>("/jobs/submit", {
method: "POST",
headers: { "Idempotency-Key": crypto.randomUUID() },
body: JSON.stringify({ job_name: "ts-first-job", job_type: "padel-descriptor", payload }),
});From here, poll Get job status or long-poll completion events, then download the zip from Download a job result (read it with response.arrayBuffer()). Every endpoint's request and response shapes are in the API reference; the raw OpenAPI document at https://api.cognichem.com/openapi.json works with OpenAPI code generators if you want typed clients.