Back to Documentation

SDKs & Libraries

Official client libraries to integrate FirmAPI into your application in minutes. Both SDKs support sandbox mode for testing without an API key.

Sandbox

No API key needed

Both SDKs include a sandbox mode that lets you test without an API key and without rate limits. The sandbox returns demo data and works the same as the production API.

PHP

use FirmApi\Client;

$client = Client::sandbox();

// Works the same as production
$company = $client->companies->byIco('51636549')->get();

JavaScript / TypeScript

import { FirmApi } from 'firmapi';

const client = FirmApi.sandbox();

// Works the same as production
const company = await client.companies.byIco('51636549');

The sandbox uses demo data and the URL api.firmapi.sk/v1/sandbox. All methods work the same as in production, so when you're done testing, simply replace Client::sandbox() / FirmApi.sandbox() with normal initialization using your API key.


PHP SDK

PHP 8.1+

Official PHP client for FirmAPI. Requires PHP 8.1+ and supports Laravel auto-discovery.

Installation

composer require firmapi/php-sdk

Quick Start

Lookup by ICO

use FirmApi\Client;

// Create a client with your API key
$client = new Client('your-api-key');

// Look up a company by ICO (base data only)
$company = $client->companies->byIco('51636549')->get();

echo $company['data']['name'];         // "Version Two s. r. o."
echo $company['data']['address'];       // "Bratislava ..."

// Include enrichment data with fluent methods
$company = $client->companies->byIco('51636549')
    ->withTax()
    ->withFinancials()
    ->withDebtorStatus()
    ->get();

echo $company['data']['tax']['dic'];          // "2120733417"
echo $company['data']['financials']['revenue']; // 12500000

// Or get everything at once
$full = $client->companies->byIco('51636549')->withAll()->get();

Search

// Search by name
$results = $client->search->byName('Version Two');

foreach ($results['data'] as $company) {
    echo $company['ico'] . ' - ' . $company['name'];
}

// Autocomplete (Select2-compatible)
$suggestions = $client->search->autocomplete('vers', limit: 5);

// Advanced multi-field search
$results = $client->search->advanced([
    'name' => 'Version',
    'city' => 'Bratislava',
]);

Batch Lookup Starter+

// Batch lookup by ICO
$batch = $client->batch->byIco(['51636549', '12345678', '87654321']);

// Check batch status
$status = $client->batch->status($batch['id']);

// Get results
$results = $client->batch->results($batch['id']);

Error Handling

use FirmApi\Exceptions\AuthenticationException;
use FirmApi\Exceptions\RateLimitException;
use FirmApi\Exceptions\ValidationException;
use FirmApi\Exceptions\ApiException;

try {
    $company = $client->companies->byIco('51636549')->get();
} catch (AuthenticationException $e) {
    // Invalid or missing API key (401)
} catch (RateLimitException $e) {
    // Rate limit exceeded (429)
    $retryAfter = $e->getRetryAfter(); // seconds
} catch (ValidationException $e) {
    // Validation error (422)
    $errors = $e->getErrors();
} catch (ApiException $e) {
    // Other API error
    $statusCode = $e->getCode();
}

All Available Methods

Method Description Returns
$client->companies->byIco($ico) Look up a company by ICO (registration number) CompanyQuery
$client->companies->byId($id) Look up a company by internal ID CompanyQuery
$client->companies->byOrsrId($id) Look up a company by ORSR ID CompanyQuery
->withTax()->withFinancials()->... Chain enrichment scopes (tax, financials, insolvency, etc.) CompanyQuery
->withAll() Include all available enrichment data CompanyQuery
->get() Execute the query and return company data array
$client->search->byName($name) Search companies by name array
$client->search->byIco($ico) Search companies by partial ICO array
$client->search->autocomplete($q) Autocomplete search (Select2-compatible) array
$client->search->advanced([...]) Advanced multi-field search array
$client->batch->byIco([...]) Starter+ Batch lookup by multiple ICOs array
$client->batch->byNames([...]) Starter+ Batch lookup by multiple names array
$client->batch->status($batchId) Get batch job status array
$client->batch->results($batchId) Get batch job results array
$client->account->usage() Get current period usage statistics array
$client->account->quota() Get remaining quota for current period array
$client->account->history($days) Get usage history array
Client::sandbox() Create a sandbox client for testing (no API key needed) Client

Available Enrichment Scopes

Method Description
withTax() Tax information (DIC, VAT number, VIES verification)
withBankAccounts() Bank account details
withContacts() Contact information (email, phone, website)
withFinancials() Financial data (revenue, profit, employees)
withDebtorStatus() Debtor status
withFinancialStatements() Financial statements
withInsolvency() Insolvency records
withCommercialBulletin() Commercial bulletin entries
withPublicContracts() Public contracts
withProcurement() Procurement records
withExecutionAuthorizations() Execution authorizations
withRpvs() Public sector partner register (RPVS)
withNbs() NBS regulation status
withTaxReliability() Tax reliability index
withErasedVat() Erased VAT registrations
withAll() Include all available enrichment data

JavaScript / TypeScript SDK

TypeScript

Official JavaScript client for FirmAPI. Works in Node.js 18+ and modern browsers with full TypeScript support.

Installation

npm install firmapi

Quick Start

Lookup by ICO

import { FirmApi } from 'firmapi';

// Create a client with your API key
const client = new FirmApi('your-api-key');

// Look up a company by ICO (base data only)
const company = await client.companies.byIco('51636549');

console.log(company.data.name);    // "Version Two s. r. o."
console.log(company.data.address); // "Bratislava ..."

// Include enrichment data with fluent methods
const detailed = await client.companies.byIco('51636549')
  .withTax()
  .withFinancials()
  .withDebtorStatus();

console.log(detailed.data.tax.dic);          // "2120733417"
console.log(detailed.data.financials.revenue); // 12500000

// Or get everything at once
const full = await client.companies.byIco('51636549').withAll();

Configuration

// Full configuration
const client = new FirmApi({
  apiKey: 'your-api-key',
  timeout: 30000,             // ms (default: 30000)
  waitForFreshData: true,     // auto-retry stale data (default: true)
  maxStaleRetries: 3,         // max retry attempts (default: 3)
});

Search

// Search by name
const results = await client.search.byName('Version Two');

for (const company of results.data) {
  console.log(`${company.ico} - ${company.name}`);
}

// Autocomplete (Select2-compatible)
const suggestions = await client.search.autocomplete('vers', 5);

// Advanced multi-field search
const advanced = await client.search.advanced({
  name: 'Version',
  city: 'Bratislava',
});

Batch Lookup Starter+

// Batch lookup by ICO
const batch = await client.batch.byIco([
  '51636549',
  '12345678',
  '87654321',
]);

// Check batch status
const status = await client.batch.status(batch.id);

// Get results when completed
const results = await client.batch.results(batch.id);

Error Handling

import {
  FirmApi,
  AuthenticationException,
  RateLimitException,
  ValidationException,
  ApiException,
} from 'firmapi';

try {
  const company = await client.companies.byIco('51636549');
} catch (e) {
  if (e instanceof AuthenticationException) {
    // Invalid or missing API key (401)
  } else if (e instanceof RateLimitException) {
    // Rate limit exceeded (429)
    console.log(e.retryAfter); // seconds
  } else if (e instanceof ValidationException) {
    // Validation error (422)
    console.log(e.errors);
  }
}

All Available Methods

Method Description Returns
client.companies.byIco(ico) Look up a company by ICO (registration number) CompanyQuery
client.companies.byId(id) Look up a company by internal ID CompanyQuery
client.companies.byOrsrId(id) Look up a company by ORSR ID CompanyQuery
.withTax().withFinancials().... Chain enrichment scopes (tax, financials, insolvency, etc.) CompanyQuery
.withAll() Include all available enrichment data CompanyQuery
client.search.byName(name, opts?) Search companies by name Promise<ApiResponse<CompanyData[]>>
client.search.byIco(ico, opts?) Search companies by partial ICO Promise<ApiResponse<CompanyData[]>>
client.search.autocomplete(q, limit?) Autocomplete search (Select2-compatible) Promise<AutocompleteResponse>
client.search.advanced({...}) Advanced multi-field search Promise<ApiResponse<CompanyData[]>>
client.batch.byIco([...]) Starter+ Batch lookup by multiple ICOs Promise<BatchResponse>
client.batch.byNames([...]) Starter+ Batch lookup by multiple names Promise<BatchResponse>
client.batch.status(batchId) Get batch job status Promise<ApiResponse<BatchStatus>>
client.batch.results(batchId) Get batch job results Promise<BatchResponse>
client.account.usage() Get current period usage statistics Promise<UsageResponse>
client.account.quota() Get remaining quota for current period Promise<QuotaResponse>
client.account.history(days?) Get usage history Promise<HistoryResponse>
FirmApi.sandbox() Create a sandbox client for testing (no API key needed) FirmApi