KVK API in Python: Easy KVK API (makkelijke kvk api) for KVK nummer opzoeken, BTW nummer validatie & bedrijfsgegevens API Nederland
Learn how to use the easy KVK API (makkelijke kvk api) in Python for KVK nummer opzoeken, BTW nummer validatie, and accessing bedrijfsgegevens API Nederland. Step-by-step guide with code examples, VIES validatie API (KVK lookup API), and the KVKBase widget.
KVK API in Python: Fetch Dutch Company Data in Three Lines of Code
Python is the most widely used language for data integrations, scripts, and backend services. When working with Dutch business data, you will eventually need a KVK API. This guide shows how to use the easy KVK API from KVKBase in Python to look up company details, validate KVK numbers, and verify VAT numbers via VIES — all through a single endpoint with no unnecessary complexity.
Why Python and the KVK API Work Well Together
Python’s requests library makes consuming REST APIs simpler than almost any other language. The Dutch company data API from KVKBase returns clean JSON responses that map directly onto Python’s built-in data structures, dataclasses, or Pydantic models.
Typical Python use cases:
- Batch CRM enrichment: loop through a list of KVK numbers and append company details
- Onboarding validation: verify on sign-up that a KVK number is active
- VAT compliance: validate customer VAT numbers via VIES before invoicing
- Data pipelines: integrate KVK open data into ETL processes or analytics dashboards
Installation and First Request
You only need the requests library. It ships with most Python environments; if not, install it with:
pip install requests
Then request a free API key at kvkbase.nl and run your first call:
import requests
API_KEY = "YOUR_API_KEY"
BASE_URL = "https://api.kvkbase.nl/api/v1"
headers = {"Authorization": f"Bearer {API_KEY}"}
# KVK number lookup
response = requests.get(f"{BASE_URL}/lookup/12345678", headers=headers)
data = response.json()
print(data["tradeName"]) # Example B.V.
print(data["isActive"]) # True
That is all. No XML parsing, no OAuth flows, no SDK required.
KVK Number Lookup: Full Example
Looking up a KVK number via the KVK lookup API returns a complete company profile:
import requests
from dataclasses import dataclass
from typing import Optional
API_KEY = "YOUR_API_KEY"
BASE_URL = "https://api.kvkbase.nl/api/v1"
@dataclass
class Address:
street: str
house_number: str
postal_code: str
city: str
@dataclass
class Company:
kvk_number: str
trade_name: str
legal_form: str
address: Address
is_active: bool
vat_number: Optional[str] = None
def fetch_company(kvk_number: str) -> Company:
url = f"{BASE_URL}/lookup/{kvk_number}"
headers = {"Authorization": f"Bearer {API_KEY}"}
response = requests.get(url, headers=headers)
response.raise_for_status()
d = response.json()
return Company(
kvk_number=d["kvkNumber"],
trade_name=d["tradeName"],
legal_form=d["legalForm"],
address=Address(
street=d["address"]["street"],
house_number=d["address"]["houseNumber"],
postal_code=d["address"]["postalCode"],
city=d["address"]["city"],
),
is_active=d["isActive"],
vat_number=d.get("vatNumber"),
)
# Usage
company = fetch_company("12345678")
print(f"{company.trade_name} — {company.address.city} — Active: {company.is_active}")
The Dutch company data API returns, among other things:
- Trade name and any additional registered names
- Full address (visiting and postal)
- Legal form (BV, NV, sole trader, foundation, etc.)
- SBI codes with main and secondary activity flags
- Date of incorporation and active/inactive status
- VAT number (where available)
Search by Company Name
Do not have the KVK number yet? Use the KVK search API to look up by name:
def search_company(name: str) -> list[dict]:
url = f"{BASE_URL}/search"
headers = {"Authorization": f"Bearer {API_KEY}"}
params = {"q": name}
response = requests.get(url, headers=headers, params=params)
response.raise_for_status()
return response.json()["results"]
# Display results
results = search_company("Coolblue")
for r in results[:5]:
print(f"{r['kvkNumber']} — {r['tradeName']} — {r['city']}")
VAT Number Validation via VIES in Python
VAT number validation is a legal requirement for intra-community transactions within the EU. The VIES validation API from KVKBase validates both Dutch and European VAT numbers directly:
def validate_vat(vat_number: str) -> dict:
"""
Validates a VAT number via VIES.
Returns: valid (bool), name, address
"""
url = f"{BASE_URL}/validate/vat"
headers = {"Authorization": f"Bearer {API_KEY}"}
params = {"vatNumber": vat_number}
response = requests.get(url, headers=headers, params=params)
response.raise_for_status()
return response.json()
# Example
result = validate_vat("NL123456789B01")
if result["valid"]:
print(f"Valid VAT number for: {result['name']}")
else:
print("VAT number is invalid or not active in VIES")
For a deep dive into VAT validation error codes, see our guide on Dutch VAT number validation via VIES.
Batch Enrichment of Dutch Company Data in Python
One of the most powerful Python use cases for the Dutch company data API is enriching lists. Suppose you have a CSV of KVK numbers and want to add trade names and addresses:
import csv
import time
import requests
API_KEY = "YOUR_API_KEY"
BASE_URL = "https://api.kvkbase.nl/api/v1"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
def enrich_csv(input_path: str, output_path: str):
with open(input_path, newline="") as infile, \
open(output_path, "w", newline="") as outfile:
reader = csv.DictReader(infile)
fields = reader.fieldnames + ["trade_name", "city", "postal_code", "is_active"]
writer = csv.DictWriter(outfile, fieldnames=fields)
writer.writeheader()
for row in reader:
kvk = row.get("kvk_number", "").strip()
if not kvk:
writer.writerow(row)
continue
try:
resp = requests.get(
f"{BASE_URL}/lookup/{kvk}",
headers=HEADERS,
timeout=5
)
if resp.status_code == 200:
d = resp.json()
row["trade_name"] = d["tradeName"]
row["city"] = d["address"]["city"]
row["postal_code"] = d["address"]["postalCode"]
row["is_active"] = d["isActive"]
except Exception as e:
print(f"Error for KVK {kvk}: {e}")
writer.writerow(row)
time.sleep(0.1) # Respect rate limits
enrich_csv("customers.csv", "customers_enriched.csv")
This is the standard pattern that data engineers use for CRM enrichment, lead scoring, and compliance screening using Dutch business data (Nederlandse bedrijfsgegevens).
KVK Open Data: What Is Available?
KVKBase provides access to KVK open data from the Dutch Commercial Register (Handelsregister). These are the publicly available details that every registered Dutch company is required to maintain. The KVK business data API exposes:
- Core details: trade name, KVK number, branch number
- Address: street, house number, postal code, city
- Legal: legal form, date of incorporation
- Activities: SBI codes with descriptions
- Status: active or dissolved
For context on how KVKBase compares to the official registry API, see our post on KVK API comparison: official vs KVKBase.
Error Handling and Retry Logic
A production-grade integration handles transient failures:
import requests
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
def create_session() -> requests.Session:
session = requests.Session()
retry = Retry(
total=3,
backoff_factor=0.5,
status_forcelist=[429, 500, 502, 503, 504],
)
adapter = HTTPAdapter(max_retries=retry)
session.mount("https://", adapter)
return session
SESSION = create_session()
def safe_lookup(kvk_number: str) -> dict | None:
try:
resp = SESSION.get(
f"https://api.kvkbase.nl/api/v1/lookup/{kvk_number}",
headers={"Authorization": f"Bearer {API_KEY}"},
timeout=10,
)
if resp.status_code == 404:
return None # KVK number not found
resp.raise_for_status()
return resp.json()
except requests.RequestException as e:
print(f"API error for {kvk_number}: {e}")
return None
The KVKBase Widget as an Alternative for Forms
Building a web application where end users enter their own company name or KVK number? The KVKBase embeddable widget is the fastest path. Drop in a single script tag and you have a working company search field immediately:
<script src="https://widget.kvkbase.nl/embed.js"
data-api-key="YOUR_API_KEY"
data-target="#company-search">
</script>
The widget is fully style-customisable and works out of the box. You can pair it with server-side Python validation: the widget handles the UI, your Python backend validates and stores the data.
Get Started: Easy KVK API in Five Minutes
The easy KVK API from KVKBase is designed to be operational in minutes, not days. Here is how to begin:
- Create a free account at kvkbase.nl
- Copy your API key from the dashboard
- Install requests:
pip install requests - Run your first lookup using the example code above
- Scale up to a paid tier once you have production traffic
The free tier provides ample capacity for prototypes and smaller integrations. As usage grows, upgrading is a single click in the dashboard — no contracts, no minimum commitments.
Questions about a specific Python integration? Reach out via kvkbase.nl — we are happy to help.