1ToolRing Docs Get a key
View as markdown
sdks/javascript

There is no official SDK package yet. The API is a plain HTTPS contract, so a thin typed client is the recommended pattern.

Minimal client

const BASE = 'https://api.1toolring.com/api/v1';

type Envelope<T> = { data: T; meta?: Record<string, unknown> };

export async function api<T>(
  path: string,
  opts: { key: string; init?: RequestInit },
): Promise<Envelope<T> & { charged: number }> {
  const res = await fetch(`${BASE}${path}`, {
    ...opts.init,
    headers: {
      Authorization: `Bearer ${opts.key}`,
      'Content-Type': 'application/json',
      ...(opts.init?.headers ?? {}),
    },
  });
  const body = await res.json();
  if (!res.ok) throw new Error(body?.error?.message ?? `HTTP ${res.status}`);
  const charged = Number(res.headers.get('x-toolring-credits') ?? 0);
  return { ...(body as Envelope<T>), charged };
}

const verdict = await api<{ result: string }>('/email/verify', {
  key: process.env.TOOLRING_KEY!,
  init: { method: 'POST', body: JSON.stringify({ email: 'user@example.com' }) },
});
console.log(verdict.data.result, verdict.charged);

Discover before you call

const res = await fetch('https://api.1toolring.com/api/v1/catalog/search?q=email');
const { data } = await res.json();
for (const entry of data.results) {
  console.log(entry.id, entry.method, entry.path, entry.price_credits, entry.price_unit);
}

The catalog is public and free, so an agent can read prices before it spends anything.

Browser note

Never ship an API key to the browser. Proxy through your own backend, or use the session-authenticated endpoints (/auth/*, /user/*) with the Bearer JWT from the dashboard flow.