SDKs, code examples and Postman

Official libraries for PHP, Node.js and Python, examples for calling the API without them, and a Postman collection to try every endpoint.

Base URL: https://spaincompanyapi.com/api/v1 · API key in the X-API-KEY header · Get a free API key (100 requests, no card) · Full documentation

15. Official SDKs (Published)

Speed up integration in your applications using our official libraries with static typing and native error handling. These SDKs are production-ready.

PHP SDK

Official

Install via Composer:

composer require apiempresas/apiempresas-php

Usage example:

require_once 'vendor/autoload.php';

use ApiEmpresas\ApiEmpresas;

$api = new ApiEmpresas('your_api_key');
$company = $api->companies->get('B12345678');
echo $company['name'];

Node.js Node.js / TS

Official

Install via NPM:

npm install apiempresas

TypeScript usage example:

import { ApiEmpresas } from 'apiempresas';

const api = new ApiEmpresas({ apiKey: 'your_api_key' });
const company = await api.companies.get('B12345678');
console.log(company.name);

Python Python SDK

Official

Install via PIP:

pip install apiempresas

Usage example:

from apiempresas import ApiEmpresas

api = ApiEmpresas('your_api_key')
company = api.companies.get('B12345678')
print(company['name'])

What's new in version 1.6.0

All three SDKs now include bulk validation of your customers' tax IDs before invoicing (POST /companies/verify/batch): companies.verifyBatch in PHP and Node and companies.verify_batch in Python. Up to 1,000 tax IDs per call, plain or with the legal name you have on file and your own reference; each one comes back with invoice_hint (ok, revisar or no_facturar) and its reasons. Update with npm install apiempresas@latest, pip install -U apiempresas or composer update apiempresas/apiempresas-php.

const { data, meta } = await api.companies.verifyBatch([
  { cif: 'A46103834', name: 'Mercadona', ref: 'customer-0001' },
  { cif: 'A15075062', name: 'Inditex', ref: 'customer-0002' },
  'B12345674',
]);
data.forEach((row) => console.log(row.input, row.invoice_hint)); // ok, revisar or no_facturar
console.log(meta.cost, 'requests');

What's new in version 1.5.0

All three SDKs now cover the October endpoints: subsidies (companies.subsidies), the changes feed (companies.changes, plus a helper that walks every page), BORME statistics (stats), the IBAN in KYB verification (checks.iban) and the filters of the company.created webhook. In Node, the types also include size, address_density and sources. Update with npm install apiempresas@latest or pip install -U apiempresas.

import { ApiEmpresas, constructWebhookEvent } from 'apiempresas';

const api = new ApiEmpresas({ apiKey: 'your_api_key' });

// KYB verification with IBAN (Pro, 2 requests)
const v = await api.companies.verify('A46103834', { name: 'Mercadona SA', iban: 'ES9121000418450200051332' });
console.log(v.decision_hint, v.checks.iban?.valid); // pass | review | fail

// Subsidies (Business, 1 request)
const s = await api.companies.subsidies('A46103834', { year: 2025 });
console.log(s.summary.total_grants, s.summary.total_amount);

// BORME changes feed, every page (Business, 1 request per page)
for await (const c of api.companies.iterateChanges({ since: '2026-10-19', types: ['address', 'officers'] })) {
  console.log(c.cif, c.change_types);
}

// BORME statistics (all plans, 1 request)
const st = await api.stats({ metrics: ['incorporations'], province: 'MADRID', from: '2025-01', to: '2025-12' });

// New companies, filtered (Business)
await api.webhooks.create({ url: 'https://your-server.com/new', event: 'company.created', filters: { province: ['MADRID'], keywords: ['software'] } });

// On your server, verify the signature with the raw body:
const evento = constructWebhookEvent(rawBody, req.headers['x-apiempresas-signature'], secret);

In Python: companies.subsidies(), companies.changes() and iter_changes(), api.stats(from_=...) and from apiempresas import construct_webhook_event. In PHP: $api->companies->subsidies(), changes() and changesAll(), $api->stats() and ApiEmpresas\Resources\Webhooks::constructEvent($raw, $firma, $secret).

16. Manual Code Examples

Implement the connection in minutes with these ready-to-use examples.

PHP PHP (cURL)

<?php
$apiKey = 'YOUR_API_KEY';
$cif = 'A15075062';
$url = 'https://spaincompanyapi.com/api/v1/companies?cif=' . $cif;

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'X-API-KEY: ' . $apiKey,
    'Accept: application/json'
]);

$response = curl_exec($ch);
$data = json_decode($response, true);
print_r($data);
?>

Laravel Laravel (HTTP Client)

use Illuminate\Support\Facades\Http;

$response = Http::withHeaders([
    'X-API-KEY' => 'YOUR_API_KEY'
])->get('https://spaincompanyapi.com/api/v1/companies', [
    'cif' => 'A15075062'
]);

if ($response->successful()) {
    $data = $response->json();
}

CodeIgniter CodeIgniter 4

$client = \Config\Services::curlrequest();

$response = $client->request('GET', 'https://spaincompanyapi.com/api/v1/companies', [
    'headers' => [
        'X-API-KEY' => 'YOUR_API_KEY',
        'Accept'    => 'application/json'
    ],
    'query' => ['cif' => 'A15075062']
]);

$data = json_decode($response->getBody(), true);

Node.js Node.js (Fetch)

const fetch = require('node-fetch');

const getCompany = async (cif) => {
  const response = await fetch('https://spaincompanyapi.com/api/v1/companies?cif=' + cif, {
    headers: { 'X-API-KEY': 'YOUR_API_KEY' }
  });
  const data = await response.json();
  console.log(data);
};

Python Python (Requests)

import requests

url = "https://spaincompanyapi.com/api/v1/companies"
params = {"cif": "A15075062"}
headers = {"X-API-KEY": "YOUR_API_KEY"}

response = requests.get(url, params=params, headers=headers)
print(response.json())

JavaScript JavaScript (Browser Fetch)

fetch('https://spaincompanyapi.com/api/v1/companies?cif=A15075062', {
  headers: {
    'X-API-KEY': 'YOUR_API_KEY',
    'Accept': 'application/json'
  }
})
.then(res => res.json())
.then(data => console.log(data));

17. Postman Collection

If you prefer to test the API directly in Postman, you can download our official collection and import it with one click.

Postman

Includes all endpoints configured, response examples and environment variables.

📥 Download Postman Collection

🚀 Ready to get started?

Get your API Key in seconds and start integrating real data into your applications.

Go to Control Panel
🤖
Asistente IA En línea
¡Hola! Soy el asistente de APIEmpresas. ¿En qué puedo ayudarte hoy?