Package Exports
- @virkly/sdk
Readme
@virkly/sdk
Official TypeScript/JavaScript SDK for the Virkly API — Danish company data.
Installation
npm install @virkly/sdk
# or
pnpm add @virkly/sdk
# or
yarn add @virkly/sdkQuick Start
import { Virkly } from "@virkly/sdk";
const virkly = new Virkly({ apiKey: "vkly_your_api_key" });
// 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"Features
- Full TypeScript type definitions for all endpoints
- Comprehensive error handling with typed error classes
- Zero dependencies (uses built-in
fetch) - Server-side only (API keys are secrets — do not use in browsers)
API Reference
Companies
// Get company by CVR
const company = await virkly.companies.get("10209545");
// Get key people (directors, board members, founders)
const people = await virkly.companies.people("10209545");
// Get financial data
const financials = await virkly.companies.financials("10209545");
const financials2023 = await virkly.companies.financials("10209545", { year: 2023 });
// Get share capital history
const capital = await virkly.companies.capital("10209545");
// Get detailed capital increase history with exchange rates
const capitalHistory = await virkly.companies.capitalHistory("10209545");
// Get production units (P-units)
const punits = await virkly.companies.productionUnits("10209545");
// Get company details (purpose, signatory rule, etc.)
const details = await virkly.companies.details("10209545");
// Get annual reports
const reports = await virkly.companies.annualReports("10209545");
// Get change history
const history = await virkly.companies.history("10209545");
// Get all data in one request
const full = await virkly.companies.full("10209545");Search
// Search for companies
const results = await virkly.search.companies({
q: "Novo Nordisk",
limit: 10,
status: "active",
});
for (const company of results.results) {
console.log(`${company.name} (CVR: ${company.cvr})`);
}People
// Get person by ERST enhedsNummer
const person = await virkly.people.get(4000068615);
console.log(person.name);
console.log(`Active roles: ${person.stats.activeRoles}`);
// Search for persons
const results = await virkly.people.search({ name: "Jensen", limit: 20 });Industries
// List all industries
const industries = await virkly.industries.list();
// Get industry details
const tech = await virkly.industries.get("620100");
console.log(`${tech.description}: ${tech.companyCount} companies`);
// List companies in an industry
const companies = await virkly.industries.companies("620100", {
page: 1,
limit: 50,
sort: "employees",
});Error Handling
The SDK throws typed errors that extend VirklyError:
import { Virkly, NotFoundError, RateLimitError, AuthenticationError } from "@virkly/sdk";
try {
const company = await virkly.companies.get("99999999");
} 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");
}
}Error Classes
| Error Class | HTTP Status | When |
|---|---|---|
ValidationError |
400 | Invalid request parameters |
AuthenticationError |
401 | Invalid or missing API key |
ForbiddenError |
403 | Insufficient permissions |
NotFoundError |
404 | Resource not found |
RateLimitError |
429 | Rate limit exceeded |
ServerError |
5xx | Server error |
Configuration
const virkly = new Virkly({
apiKey: "vkly_your_api_key", // Required
baseUrl: "https://virkly.io", // Optional, defaults to production
timeout: 30000, // Optional, request timeout in ms (default: 30s)
});Requirements
- Node.js 18+ (uses built-in
fetch) - Server-side only (API keys must not be exposed to browsers)