Node SDK

The API from JavaScript and TypeScript.

Install

Terminal
npm install handelsregister
export HANDELSREGISTER_API_KEY=YOUR_API_KEY
What
What Value
Package handelsregister
Current version 0.7.0
Node.js 22.13 or newer
TypeScript Type definitions included
License AGPL-3.0
Source code github.com/Handelsregister-AI/handelsregister-js

First request

JavaScript
import { Handelsregister } from 'handelsregister';

const client = new Handelsregister({ apiKey: process.env.HANDELSREGISTER_API_KEY });

const company = await client.fetchOrganization({ q: 'Hetzner Online GmbH' });
console.log(company.entity_id, company.name);
console.log(company.registration); // { court: 'Ansbach', register_type: 'HRB', register_number: '6089' }
console.log(company.meta.request_credit_cost);
1{2  "entity_id": "94eb910fef13f94585c48c263fa446d4",3  "name": "Hetzner Online GmbH",4  "status": "ACTIVE",5  "legal_form": "GmbH",6  "registration": {7    "court": "Ansbach",8    "register_type": "HRB",9    "register_number": "6089"10  },11  "meta": {12    "request_credit_cost": 5,13    "credits_remaining": 14514  }15}
200 · Excerpt from our example response for Hetzner Online GmbH, Ansbach HRB 6089, basic data only
JavaScript
const company = await client.fetchOrganization({
  q: 'Ansbach HRB 6089',
  features: ['financial_kpi', 'related_persons'],
});
For one hour, the client answers identical requests from its cache, without new credits. Requests with Realtime always go to the API. Set cacheEnabled: false to turn the cache off.

Handle errors

Exception
Exception Status Meaning
AuthenticationError 401 Missing or invalid API key.
InsufficientCreditsError 402 Your balance is not enough for this request.
SubscriptionRequiredError 403 The request needs a higher plan. requiredPlans names the plans that fit.
NotFoundError 404 No matching company or person found.
RequestTimeoutError 408 The register did not answer in time. Nothing was charged.
RequestValidationError 400, 422 A parameter has an invalid value.
RateLimitError 429 Too many requests per minute.
ServerError 5xx The data source is unavailable or overloaded right now. Retry later.
JavaScript
import {
  Handelsregister,
  HandelsregisterError,
  InsufficientCreditsError,
  NotFoundError,
  RequestTimeoutError,
} from 'handelsregister';

const client = new Handelsregister({ timeout: 120000 });

try {
  const company = await client.fetchOrganization({
    q: 'Hetzner Online GmbH',
    realtimeMode: true,
  });
} catch (error) {
  if (error instanceof NotFoundError) {
    console.log('No matching company found');
  } else if (error instanceof InsufficientCreditsError) {
    console.log('Not enough credits:', error.meta);
  } else if (error instanceof RequestTimeoutError) {
    console.log('The register is not answering right now, try again later');
  } else if (error instanceof HandelsregisterError) {
    console.log('Error:', error.statusCode, error.message);
  } else {
    throw error;
  }
}

Command line

Terminal
# Company profile without AI Mode, with Financial KPIs only
npx handelsregister fetch "Hetzner Online GmbH" --no-ai-search --feature financial_kpi

# Save the shareholder list as a PDF
npx handelsregister document "Hetzner Online GmbH" --type shareholders_list --output hetzner.pdf
Without further options, handelsregister fetch turns on AI Mode. A request then costs 25 credits instead of 5, even without features. With --no-ai-search, you request without AI Mode.

Reference