JavaScript and TypeScript SDK
A typed fetch-based client for Node.js and server runtimes.
Install the verified build. The SDK supports Node.js 18+ and typed TypeScript imports. Constructor options can supply a key, base URL, timeout, retries or a custom fetch. Environment defaults are CYBERRXN_API_KEY and CYBERRXN_BASE_URL.
Search and inspect
import { CyberRXN } from 'cyberrxn';
const client = new CyberRXN();
const page = await client.moleculeReactions(
'CCN1CCN(CO)C(=O)C1=O', { role: 'product', limit: 3 }
);
if (page.items.length) {
const observation = await client.getObservation(page.items[0]!.observation_id);
console.log(observation.paragraph_text);
}Request options use camelCase; response JSON keeps API snake_case. Observation identifiers remain opaque.
Chemistry utilities
import { CyberRXN } from 'cyberrxn';
const client = new CyberRXN();
const validation = await client.validateReaction('CCO>>CC=O');
console.log(validation.valid, validation.atom_balance.delta);
const balance = await client.balanceReaction('[H][H].O=O>>O');
if (balance.solved && balance.balanced_reaction_smiles) {
const formula = await client.convertSmiles(balance.balanced_reaction_smiles);
console.log(formula.unicode);
}Call convertRepresentation(data, { inputFormat, outputFormat, allowLossy }) for the universal converter. Use getReactionSkill() for current guide and live action schemas.
Paging and response metadata
searchReactions, lookupReaction and moleculeReactions return a PagePromise: await it for one page, or iterate it with for await to follow pages. Every fetched page consumes a call. Do not iterate an entire corpus accidentally.
Top-level objects expose non-enumerable lastResponse metadata, including the support request ID and parsed usage header. Keep request IDs when reporting a service failure.
Curation methods
Use reportObservationIssue, reports, getReport, submitReactionContribution, contributions and getContribution. Write input includes a stable idempotencyKey; the client maps it to API idempotency_key. A response in pending or needs_review is not a published or corrected fact.
Errors and browser use
APIError contains status, code, retryable and requestId; typed subclasses correspond to HTTP statuses. Fix an invalid request before retrying. An HTTP 200 chemistry verdict with valid:false should be handled as data.
Keep private API keys on your server. The constructor blocks accidental browser use by default. OAuth in the CyberRXN dashboard provides a browser workflow without exposing a long-lived API key to visitors.