@companybook/sdk
v0.1.0-beta.0
Published
Official TypeScript client for the Companybook REST API (Norwegian company data). Zero runtime dependencies.
Readme
@companybook/sdk (beta)
Official TypeScript client for the Companybook REST API: Norwegian company data (register, accounts, subunits, web presence, group structure). Zero runtime dependencies, Node 20+.
import { Companybook, CompanybookError } from '@companybook/sdk';
const cb = new Companybook({ apiKey: process.env.COMPANYBOOK_API_KEY });
await cb.me(); // { api_access: true, tier: 'plus', ... }
// The nightly-sync recipe: dedupe, sequential chunks of 50, merged extensions.
const { entities, extensions, missing, units } = await cb.entities.batchAll(['923609016', '817209882'], {
extend: ['financial_history', 'web_identities', 'group_parent'],
});
// All subunits of one hovedenhet (up to 1 000; `truncated` says when cut).
const { subunits, truncated } = await cb.entities.subunits('817209882');
const hits = await cb.resolve({ query: 'Vinmonopolet', types: ['org'], limit: 5 });- A REST API key needs Plus or Business Plus. Create it under Agenttilgang. Keep it in an environment variable on a server.
CompanybookErrorcarriesstatus,code,retryAfter,requiredTier,fatalandretryable. The client waitsRetry-Afteron429and retries503; it never retries400/401/402/403.- The client never prints the key (
JSON.stringifyandinspectredact it).
Contract: /api/v1/openapi.json.
test/sdk/contract.test.ts in the Companybook repo keeps this package equal to the server.
