VirklyVirkly

API-dokumentation

Få adgang til danske virksomhedsdata programmatisk med vores RESTful API.

JavaScript SDK

Brug det officielle TypeScript/JavaScript SDK for en typesikker og ergonomisk udvikleroplevelse

Installation

Installer SDK'et fra npm:

npm install @virkly/sdk

Initialiser klienten

Opret en Virkly-klientinstans med din API key:

import { Virkly } from "@virkly/sdk";

const virkly = new Virkly({ apiKey: "vkly_your_api_key" });

Virksomheder

Slå virksomheder op med CVR-nummer og tilgå relaterede data:

// Look up a company by CVR number
const company = await virkly.companies.get("10209545");
console.log(company.name); // "Novo Nordisk A/S"
console.log(company.status); // "active"

// Get key people (directors, board members, owners)
const people = await virkly.companies.people("10209545");
for (const person of people.people) {
  console.log(`${person.name} — ${person.role}`);
}

// Get financial data
const financials = await virkly.companies.financials("10209545");
console.log(financials.latestFinancials?.revenue);
console.log(financials.latestFinancials?.netProfit);

// Get financials for a specific year
const fin2023 = await virkly.companies.financials("10209545", { year: 2023 });

// Get share capital history
const capital = await virkly.companies.capital("10209545");
console.log(capital.currentCapital);
console.log(capital.summary.netChange);

// Get detailed capital increase history with valuations
const increases = await virkly.companies.capitalHistory("10209545");
for (const inc of increases.increases) {
  console.log(`${inc.date}: ${inc.increaseAmount} DKK`);
}

// Get company details (purpose, signatory rule, etc.)
const details = await virkly.companies.details("10209545");
console.log(details.details.purpose);

// Get production units
const punits = await virkly.companies.productionUnits("10209545");
console.log(`${punits.totalUnits} production units`);

// Get annual reports
const reports = await virkly.companies.annualReports("10209545");
for (const report of reports.reports) {
  console.log(`${report.year}: ${report.documentUrl}`);
}

// Get change history
const history = await virkly.companies.history("10209545");

// Get all data in a single request
const full = await virkly.companies.full("10209545");

Søgning

Søg efter virksomheder med navn eller CVR-nummer:

// Search by company name
const results = await virkly.search.companies({ q: "Novo Nordisk" });
console.log(`Found ${results.total} companies`);

for (const company of results.results) {
  console.log(`${company.name} (CVR: ${company.cvr})`);
}

// Paginated search with filters
const page2 = await virkly.search.companies({
  q: "software",
  limit: 10,
  offset: 10,
  status: "active",
});

Personer

Slå personer op og søg efter navn:

// Look up a person by their ERST enhedsNummer
const person = await virkly.people.get(4000068615);
console.log(person.name);
console.log(`Active roles: ${person.stats.activeRoles}`);
console.log(`Board roles: ${person.stats.boardRoles}`);

// Browse their company roles
for (const role of person.roles) {
  console.log(`${role.companyName} — ${role.role} (since ${role.since})`);
}

// Search for people by name
const results = await virkly.people.search({ name: "Jensen" });
for (const p of results.results) {
  console.log(`${p.name} (${p.enhedsNummer})`);
}

Brancher

Gennemse brancher og list virksomheder inden for dem:

// List all industries
const industries = await virkly.industries.list();
for (const ind of industries.industries) {
  console.log(`${ind.code}: ${ind.description} (${ind.companyCount} companies)`);
}

// Get details for a specific industry (NACE code)
const detail = await virkly.industries.get("620100");
console.log(`${detail.description}: ${detail.companyCount} companies`);

// List companies in an industry
const companies = await virkly.industries.companies("620100", {
  page: 1,
  limit: 20,
  sort: "employees",
});

Fejlhåndtering

SDK'et kaster typede fejl, som du kan fange og håndtere:

import {
  Virkly,
  NotFoundError,
  RateLimitError,
  AuthenticationError,
  VirklyError,
} from "@virkly/sdk";

const virkly = new Virkly({ apiKey: "vkly_your_api_key" });

try {
  const company = await virkly.companies.get("00000000");
} catch (error) {
  if (error instanceof NotFoundError) {
    console.log("Company not found");
  } else if (error instanceof RateLimitError) {
    console.log(`Rate limited. Retry after ${error.retryAfter} seconds`);
  } else if (error instanceof AuthenticationError) {
    console.log("Invalid API key");
  } else if (error instanceof VirklyError) {
    console.log(`API error ${error.status}: ${error.message}`);
  }
}

Konfiguration

Klienten accepterer følgende konfigurationsmuligheder:

apiKeyrequired

Din Virkly API key (påkrævet, starter med vkly_)

baseUrloptional

Tilsidesæt base URL (standard: https://virkly.io)

timeoutoptional

Request timeout i millisekunder (standard: 30000)