Company registry API examples
Company registry API examples in cURL, Python and JavaScript show how to find a company, check a registry number and list officers.
The Sample output tabs show what each program prints for the fictional Example Robotics Oy; those values do not establish registry coverage. Put the name or number you need in its place.
The free tier of the company registry API at CompanyRegistryAPI.com: no key or account, 60 requests per minute per client address.
Find a company by name
Searches for companies whose name starts with “example robotics” and whose address is in Finland, then prints each result's company ID, name and status category, and labels a record that is not current. Keep the company ID of the one you choose for the next requests.
It reads the first page of results. The Company Search API page explains how results are ordered and how to ask for the next page.
The results come from official company registers through Coragrid, the source-linked company data infrastructure behind this API.
# No key needed; uses jqbase=https://api.companyregistryapi.com# Prints the API's problem, or one line otherwiseproblem() { jq -er 'select(.status) | "Error \(.status): \(.detail)"' <<<"$1" \ 2>/dev/null || echo "Error: unexpected response"}# Returns 1 when the request fails, 0 otherwisefind_company() { local page page=$(curl -sSG "$base/v1/search" \ --data-urlencode "q=example robotics" \ -d address_country=FI) || return 1 if ! jq -e '.data | type == "array"' <<<"$page" \ >/dev/null 2>&1; then problem "$page" return 1 fi jq -r ' def note: .lifecycle | select((.status // "active") != "active") | (.successor_ids // [] | join(", ")) as $ids | if .status == "redirected" and .canonical_id then "redirected to \(.canonical_id)" elif .status == "split" and $ids != "" then "split into \($ids)" else .status end; if .data == [] then "No company matches the search" else .data[] | [.id, .name // "", (.company_status.category? // ""), note] | @tsv end ' <<<"$page"}find_companyimport jsonimport sysfrom urllib.error import HTTPErrorfrom urllib.parse import urlencodefrom urllib.request import urlopenBASE = "https://api.companyregistryapi.com"def get(path, **params): url = f"{BASE}{path}?{urlencode(params)}" try: with urlopen(url, timeout=30) as response: return json.load(response) except HTTPError as error: try: detail = json.load(error)["detail"] except (ValueError, KeyError, TypeError): detail = error.reason sys.exit(f"Error {error.code}: {detail}")# Labels a record that is not current, else ""def lifecycle_note(company): life = company.get("lifecycle") or {} status = life.get("status", "active") target = life.get("canonical_id") ids = ", ".join(life.get("successor_ids", [])) if status == "redirected" and target: return f"redirected to {target}" if status == "split" and ids: return f"split into {ids}" return "" if status == "active" else statuspage = get("/v1/search", q="example robotics", address_country="FI")if not page["data"]: print("No company matches the search")for company in page["data"]: # A string status is the register's own wording status = company.get("company_status") if not isinstance(status, dict): status = {} row = [company["id"], company.get("name", ""), status.get("category", "")] note = lifecycle_note(company) if note: row.append(note) print(*row, sep="\t")const BASE = "https://api.companyregistryapi.com";async function get(path, params = {}) { const url = new URL(path, BASE); url.search = new URLSearchParams(params); const response = await fetch(url); const body = await response.json().catch(() => ({})); if (!response.ok) { const detail = body.detail ?? response.statusText; const status = response.status; throw new Error(`Error ${status}: ${detail}`); } return body;}// Labels a record that is not current, else ""function lifecycleNote(company) { const life = company.lifecycle ?? {}; const status = life.status ?? "active"; const ids = life.successor_ids ?? []; if (status === "redirected" && life.canonical_id) { return `redirected to ${life.canonical_id}`; } if (status === "split" && ids.length > 0) { return `split into ${ids.join(", ")}`; } return status === "active" ? "" : status;}async function main() { const page = await get("/v1/search", { q: "example robotics", address_country: "FI", }); if (page.data.length === 0) { console.log("No company matches the search"); } for (const company of page.data) { const name = company.name ?? ""; const status = company.company_status ?? {}; const category = status.category ?? ""; const row = [company.id, name, category]; const note = lifecycleNote(company); if (note) row.push(note); console.log(row.join("\t")); }}main().catch((error) => { console.error(error.message); process.exitCode = 1;});co_014d2pf2dbsqqg28t5cy4tqkff Example Robotics Oy activeCheck a registry number
Searches for the Finnish business ID 1234567-8 and reads the details of each result on the first page of matches, because search results carry no registry identifiers. It prints the registration status from the entry matching the number, scheme and jurisdiction. A record that is not current shows its lifecycle instead: redirected to the current record, split into its successors, tombstoned or restricted. An ended registration is a former number. “Not stated” means the entry has no status, and “not listed” means this response contains no entry matching all three. For a compliance decision, confirm the result with the company's home register.
# No key needed; uses jqbase=https://api.companyregistryapi.comscheme=national_registry_numbernumber=1234567-8 country=FI# Prints the API's problem, or one line otherwiseproblem() { jq -er 'select(.status) | "Error \(.status): \(.detail)"' <<<"$1" \ 2>/dev/null || echo "Error: unexpected response"}# Returns 1 when a request fails, 0 otherwisecheck_number() { local page co id row rows=() page=$(curl -sSG "$base/v1/search" \ --data-urlencode "q=$number" \ -d "jurisdiction=$country") || return 1 if ! jq -e '.data | type == "array"' <<<"$page" \ >/dev/null 2>&1; then problem "$page" return 1 fi if jq -e '.data == []' <<<"$page" >/dev/null; then echo "No company matches the search" return 0 fi for id in $(jq -r '.data[].id' <<<"$page"); do co=$(curl -sS "$base/v1/companies/$id") || return 1 if ! jq -e '.data | type == "object"' <<<"$co" \ >/dev/null 2>&1; then problem "$co" return 1 fi row=$(jq -r --arg s "$scheme" --arg n "$number" \ --arg c "$country" ' def note: .lifecycle | select((.status // "active") != "active") | (.successor_ids // [] | join(", ")) as $ids | if .status == "redirected" and .canonical_id then "redirected to \(.canonical_id)" elif .status == "split" and $ids != "" then "split into \($ids)" else .status end; .data as $co | [$co.identifiers[]? | select(.scheme == $s and .value == $n and .country_scope == $c)] | [$co.id, $co.name // "", $n, ($co | note) // (if . == [] then "not listed" else .[0].status // "not stated" end)] | @tsv ' <<<"$co") rows+=("$row") done printf '%s\n' "${rows[@]}" if jq -e '.next_cursor' <<<"$page" >/dev/null; then echo "More matches on later pages:" \ "narrow the search or page with next_cursor" fi}check_numberimport jsonimport sysfrom urllib.error import HTTPErrorfrom urllib.parse import urlencodefrom urllib.request import urlopenBASE = "https://api.companyregistryapi.com"def get(path, **params): url = f"{BASE}{path}?{urlencode(params)}" try: with urlopen(url, timeout=30) as response: return json.load(response) except HTTPError as error: try: detail = json.load(error)["detail"] except (ValueError, KeyError, TypeError): detail = error.reason sys.exit(f"Error {error.code}: {detail}")# Labels a record that is not current, else ""def lifecycle_note(company): life = company.get("lifecycle") or {} status = life.get("status", "active") target = life.get("canonical_id") ids = ", ".join(life.get("successor_ids", [])) if status == "redirected" and target: return f"redirected to {target}" if status == "split" and ids: return f"split into {ids}" return "" if status == "active" else statusscheme = "national_registry_number"number, country = "1234567-8", "FI"page = get("/v1/search", q=number, jurisdiction=country)if not page["data"]: print("No company matches the search")rows = []for result in page["data"]: path = f"/v1/companies/{result['id']}" company = get(path)["data"] hits = [ entry for entry in company.get("identifiers", []) if entry.get("scheme") == scheme and entry.get("value") == number and entry.get("country_scope") == country ] if hits: found = hits[0].get("status", "not stated") else: found = "not listed" found = lifecycle_note(company) or found name = company.get("name", "") rows.append((company["id"], name, number, found))for row in rows: print(*row, sep="\t")if rows and page.get("next_cursor"): print("More matches on later pages:", "narrow the search or page with next_cursor")const BASE = "https://api.companyregistryapi.com";async function get(path, params = {}) { const url = new URL(path, BASE); url.search = new URLSearchParams(params); const response = await fetch(url); const body = await response.json().catch(() => ({})); if (!response.ok) { const detail = body.detail ?? response.statusText; const status = response.status; throw new Error(`Error ${status}: ${detail}`); } return body;}// Labels a record that is not current, else ""function lifecycleNote(company) { const life = company.lifecycle ?? {}; const status = life.status ?? "active"; const ids = life.successor_ids ?? []; if (status === "redirected" && life.canonical_id) { return `redirected to ${life.canonical_id}`; } if (status === "split" && ids.length > 0) { return `split into ${ids.join(", ")}`; } return status === "active" ? "" : status;}async function main() { const scheme = "national_registry_number"; const number = "1234567-8"; const country = "FI"; const page = await get("/v1/search", { q: number, jurisdiction: country, }); if (page.data.length === 0) { console.log("No company matches the search"); } const rows = []; for (const result of page.data) { const path = `/v1/companies/${result.id}`; const { data: company } = await get(path); const hit = (company.identifiers ?? []).find( (entry) => entry.scheme === scheme && entry.value === number && entry.country_scope === country, ); let found = "not listed"; if (hit) found = hit.status ?? "not stated"; found = lifecycleNote(company) || found; const name = company.name ?? ""; const row = [company.id, name, number, found]; rows.push(row.join("\t")); } for (const line of rows) console.log(line); if (rows.length > 0 && page.next_cursor) { console.log("More matches on later pages:", "narrow the search or page with next_cursor"); }}main().catch((error) => { console.error(error.message); process.exitCode = 1;});co_014d2pf2dbsqqg28t5cy4tqkff Example Robotics Oy 1234567-8 activeList a company's officers
Takes the first company the name search returns and prints its current officers and their roles where the register publishes them, up to 100. When has_more is true, the register lists more officers, and the program says so in a last line.
# No key needed; uses jqbase=https://api.companyregistryapi.com# Prints the API's problem, or one line otherwiseproblem() { jq -er 'select(.status) | "Error \(.status): \(.detail)"' <<<"$1" \ 2>/dev/null || echo "Error: unexpected response"}# Returns 1 when a request fails, 0 otherwiselist_officers() { local page id name list page=$(curl -sSG "$base/v1/search" \ --data-urlencode "q=example robotics" \ -d address_country=FI) || return 1 if ! jq -e '.data | type == "array"' <<<"$page" \ >/dev/null 2>&1; then problem "$page" return 1 fi # The first match: check it is the company you mean id=$(jq -r '.data[0].id // empty' <<<"$page") if [ -z "$id" ]; then echo "No company matches the search" return 0 fi name=$(jq -r '.data[0].name // ""' <<<"$page") list=$(curl -sS "$base/v1/companies/$id/officers") || return 1 if ! jq -e '.data | type == "array"' <<<"$list" \ >/dev/null 2>&1; then problem "$list" return 1 fi jq -r --arg name "$name" ' (.company_id as $id | [$id, if $id == .requested_company_id then $name else "" end] | @tsv), (if .data == [] then " No current officers returned" else .data[] | " \(.name)\t\(.roles // [] | join(", "))" end), (if .has_more then " The register lists more officers" else empty end) ' <<<"$list"}list_officersimport jsonimport sysfrom urllib.error import HTTPErrorfrom urllib.parse import urlencodefrom urllib.request import urlopenBASE = "https://api.companyregistryapi.com"def get(path, **params): url = f"{BASE}{path}?{urlencode(params)}" try: with urlopen(url, timeout=30) as response: return json.load(response) except HTTPError as error: try: detail = json.load(error)["detail"] except (ValueError, KeyError, TypeError): detail = error.reason sys.exit(f"Error {error.code}: {detail}")page = get("/v1/search", q="example robotics", address_country="FI")if not page["data"]: print("No company matches the search") sys.exit()# The first match: check it is the company you meancompany = page["data"][0]path = f"/v1/companies/{company['id']}/officers"officers = get(path)owner = officers["company_id"]name = company.get("name", "")print(owner, name if owner == company["id"] else "", sep="\t")if not officers["data"]: print(" No current officers returned")for officer in officers["data"]: roles = ", ".join(officer.get("roles", [])) print(f" {officer.get('name', '')}\t{roles}")if officers.get("has_more"): print(" The register lists more officers")const BASE = "https://api.companyregistryapi.com";async function get(path, params = {}) { const url = new URL(path, BASE); url.search = new URLSearchParams(params); const response = await fetch(url); const body = await response.json().catch(() => ({})); if (!response.ok) { const detail = body.detail ?? response.statusText; const status = response.status; throw new Error(`Error ${status}: ${detail}`); } return body;}async function main() { const page = await get("/v1/search", { q: "example robotics", address_country: "FI", }); if (page.data.length === 0) { console.log("No company matches the search"); return; } // The first match: check it is the company you mean const company = page.data[0]; const path = `/v1/companies/${company.id}/officers`; const officers = await get(path); const owner = officers.company_id; const name = company.name ?? ""; console.log([owner, owner === company.id ? name : ""] .join("\t")); if (officers.data.length === 0) { console.log(" No current officers returned"); } for (const officer of officers.data) { const roles = (officer.roles ?? []).join(", "); console.log(` ${officer.name ?? ""}\t${roles}`); } if (officers.has_more) { console.log(" The register lists more officers"); }}main().catch((error) => { console.error(error.message); process.exitCode = 1;});co_014d2pf2dbsqqg28t5cy4tqkff Example Robotics Oy Anna Virtanen Chief executive officerPython examples with the standard library
The Python examples use only the standard library (urllib.request and json), so they need Python 3.8 or later and no package to install. Save one as a file and run it with python3.
Each example follows the search, choose and read steps of the Company Data API page with these requests:
- Find a company by name
- GET /v1/search with q and address_country.
- Check a registry number
- GET /v1/search with q and jurisdiction, then GET /v1/companies/{company_id} for each result.
- List a company's officers
- GET /v1/search with q and address_country, then GET /v1/companies/{company_id}/officers for the first result.
Errors and limits
When the API returns a problem response, a program prints one line with the HTTP status and the problem's detail and stops, such as 404 when no company is visible under an ID, or 429 with the seconds to wait. A search with no results prints “No company matches the search”. The API docs list every problem code.
Frequently asked questions
Do the examples need an API key?
No. The free API takes no key or account, so the examples send no credentials.
Which Python and Node versions do they need?
Python 3.8 or later with its standard library, and Node.js 18 or later, whose built-in fetch the JavaScript examples use. The cURL examples run in bash and need curl and jq. On early Node 18 releases, run node --no-warnings example.js to omit Node's experimental fetch warning.
Why can a field be missing in the output?
A field can be blank when the source supplies no value, as the Company Information API page explains.
May I use the examples in my own product?
Yes. Copy the programs into your own code and adapt them. Wherever you display the company data they fetch, show it as powered by Coragrid and follow any licence terms supplied with the records.
Run the first example.
Paste it into a file and run it; it needs no key or account. Request a Coragrid API key when you need batch reads.
