Disclosure: I built the Apify Actor mentioned near the end of this post.

The Companies House API key is free. You send it as the HTTP Basic auth username with an empty password, so the header is Authorization: Basic base64("YOUR_KEY:"). Put the key in the password slot and you get HTTP 400; send it as a Bearer token or leave it out and you get 401. With that one detail right, the standard library is enough to search companies by name and look up a list of company numbers.

This post covers getting a key, the request format, what each wrong format returns (I tried them), a script that searches by name and turns a list of company numbers into a CSV, and the rate limit.

How do I get a Companies House API key?

  1. Create a free account on the Companies House Developer Hub.
  2. Create an application, then add a key to it and choose the REST key type. The stream key is for the separate Streaming API; the endpoints below need a REST key.
  3. Copy the key into an environment variable instead of your script:
export COMPANIES_HOUSE_API_KEY='paste-your-key-here' 

The authorisation guide describes it as registering "as an API Key application". The key and the API are free.

How do I send the key?

As HTTP Basic auth: the key is the username, the password is empty. With curl that is -u "$KEY:" (note the colon):

curl -s -u "$COMPANIES_HOUSE_API_KEY:" \ https://api.company-information.service.gov.uk/company/00445790 

In Python without requests, build the header yourself: base64 of the key followed by a colon.

import base64 token = base64.b64encode((key + ":").encode()).decode() headers = {"Authorization": "Basic " + token} 

With requests it is auth=(key, "").

Why is my Companies House API key not working?

These are the responses I got on 2026-12-02 for /company/00445790, with a working key sent in different ways:

What I sent HTTP status
Key as Basic username, empty password 200
Key as Basic password, empty username 400
Authorization: Bearer <key> 401
No Authorization header 401
A made-up key as Basic username 401, body {"error":"Invalid Authorization","type":"ch:service"}

So a 401 means the API did not get a key it accepts: wrong scheme, missing header, a typo, or a key that is not a REST key. A 400 on every request is worth checking for the swapped username/password. If the call runs in a browser, the key is visible to anyone who opens the developer tools, and the Stack Overflow 401 question is a jQuery call; keep the key on a server.

Two 404s that look like key problems but are not:

Company number sent HTTP status
445790 (Tesco, without leading zeros) 404
sc083026 (lowercase prefix) 404

Company numbers are 8 characters. Pad all-digit numbers with zeros to 8 (445790 → 00445790) and uppercase the letter prefix (SC, OC, NI…). Spreadsheets are the usual reason the zeros go missing.

How do I search Companies House by company name in Python?

The name search is GET /search/companies?q=<name>. It is ranked by relevance and returns company_number, title, company_status and date_of_creation for each hit. For full details, take the number and call GET /company/{number}.

Here is a script that does both. Standard library only (tested with Python 3.9); the key comes from the environment:

import base64 import csv import json import os import sys import time import urllib.error import urllib.parse import urllib.request API = "https://api.company-information.service.gov.uk" PAUSE = 0.6 # 600 requests per 5 minutes = 1 every 0.5 s; stay a little under class CompaniesHouseError(Exception): pass def get(path, key, params=None): url = API + path if params: url += "?" + urllib.parse.urlencode(params) # The key is the Basic auth *username*; the password is empty. token = base64.b64encode((key + ":").encode()).decode() req = urllib.request.Request(url, headers={"Authorization": "Basic " + token}) for attempt in range(3): try: with urllib.request.urlopen(req, timeout=20) as resp: time.sleep(PAUSE) return json.load(resp) except urllib.error.HTTPError as e: if e.code == 401: raise CompaniesHouseError("401: key rejected (wrong key, or a key that is not a REST key)") if e.code == 404: return None # no company with that number if e.code == 429 and attempt < 2: reset = int(e.headers.get("X-Ratelimit-Reset", "0")) # Unix time the window resets time.sleep(max(1, reset - int(time.time()))) continue raise CompaniesHouseError(f"HTTP {e.code} for {path}") raise CompaniesHouseError("gave up after 3 tries") def normalize_number(n): """Companies House numbers are 8 characters: pad all-digit numbers with zeros.""" n = n.strip().upper() return n.zfill(8) if n.isdigit() else n def search_by_name(name, key, limit=5): data = get("/search/companies", key, {"q": name, "items_per_page": limit}) return [(i["company_number"], i["title"], i.get("company_status", ""), i.get("date_of_creation", "")) for i in data.get("items", [])] def company_row(number, key): c = get("/company/" + normalize_number(number), key) if c is None: return {"company_number": normalize_number(number), "company_name": "NOT FOUND"} addr = c.get("registered_office_address", {}) return { "company_number": c["company_number"], "company_name": c["company_name"], "status": c.get("company_status", ""), "type": c.get("type", ""), "incorporated": c.get("date_of_creation", ""), "postcode": addr.get("postal_code", ""), "sic_codes": " ".join(c.get("sic_codes", [])), "accounts_next_due": c.get("accounts", {}).get("next_due", ""), } if __name__ == "__main__": key = os.environ.get("COMPANIES_HOUSE_API_KEY") if not key: sys.exit("Set COMPANIES_HOUSE_API_KEY first") print("Search 'marks and spencer group':") for row in search_by_name("marks and spencer group", key, limit=3): print(" " + " | ".join(row)) print() numbers = ["445790", "00102498", "SC083026", "99999999"] rows = [company_row(n, key) for n in numbers] fields = ["company_number", "company_name", "status", "type", "incorporated", "postcode", "sic_codes", "accounts_next_due"] writer = csv.DictWriter(sys.stdout, fieldnames=fields, restval="") writer.writeheader() writer.writerows(rows) 

Run it:

python3 ch_lookup.py 

Output from my runs on 2026-12-02 (6 requests per run). I ran it twice, 30 seconds apart, and both outputs were identical:

Search 'marks and spencer group': 04256886 | MARKS AND SPENCER GROUP P.L.C. | active | 2001-07-23 00214436 | MARKS AND SPENCER P.L.C. | active | 1926-06-17 14228803 | MARKS AND SPENCER (A2B) LIMITED | active | 2022-07-12 company_number,company_name,status,type,incorporated,postcode,sic_codes,accounts_next_due 00445790,TESCO PLC,active,plc,1947-11-27,AL7 1GA,47110,2027-08-26 00102498,BP P.L.C.,active,plc,1909-04-14,SW1Y 4PD,70100,2027-06-30 SC083026,THE ROYAL BANK OF SCOTLAND PUBLIC LIMITED COMPANY,active,plc,1983-05-09,EH2 2YB,64191,2027-06-30 99999999,NOT FOUND,,,,,, 

And the 401 path, with a made-up key passed to the same get():

from ch_lookup import get, CompaniesHouseError try: get("/company/00445790", "not-a-real-key") except CompaniesHouseError as e: print(e) 
401: key rejected (wrong key, or a key that is not a REST key) 

Notes on the output:

  • The name search puts the group holding company first, then the trading company. A name search is a relevance ranking, not an exact match. If you need one specific company, check the number before you store it.
  • 445790 was padded to 00445790 by normalize_number; without it the request is a 404.
  • 99999999 does not exist. The API answers 404 with "Resource not found for company profile 99999999", and the script writes a NOT FOUND row instead of stopping.
  • accounts_next_due and sic_codes come from the company profile. Officers, persons with significant control and filing history are separate endpoints (/company/{number}/officers, /company/{number}/persons-with-significant-control, /company/{number}/filing-history), one request each per company.

What I did not test: the 429 retry path (I never got near the limit) and network errors.

What is the Companies House API rate limit?

600 requests per 5 minutes per key (rate limiting guide). Every response carries the current state in headers; these are from one of my requests:

x-ratelimit-limit: 600 x-ratelimit-window: 5m x-ratelimit-remain: 599 x-ratelimit-reset: 1796183323 

x-ratelimit-reset is a Unix timestamp. Over the limit you get 429 until then, which is what the retry in get() waits for. The fixed 0.6-second pause keeps one script under the limit on its own; if two scripts share a key, they share the 600.

In practice: one company profile is one request, so 1,000 companies need at least a little over 8 minutes at the official limit (longer with this script, because the 0.6-second pause comes on top of each response time). Adding officers, PSC and filing history adds one request per company for each.

Is there a hosted option that needs no API key?

I built an Apify Actor, Companies House UK Company Search – Official Register Data, that does the lookups above and returns one row per company. You do not need a Companies House API key for it: it calls the official API with its own built-in key, so you can just press Start. If you already have your own free key, you can optionally enter it to get your own allowance. It takes company numbers, name searches or the advanced search filters (SIC code, status, company type, location, incorporation date).

Input (field names from the README):

{ "companyNumbers": ["00445790", "SC083026"], "searchQueries": ["marks and spencer group"], "maxItems": 100 } 

From the README:

  • Company numbers are normalized the same way as above (6 → 00000006); numbers in other formats are rejected before any request is sent. If you enter your own key and it is wrong, the run stops at the first request with "Companies House rejected the API key you entered in apiKey"; leave apiKey empty to use the built-in key.
  • With the built-in key, the official allowance (600 requests per 5 minutes) is shared by everyone, so a run makes at most 1 request per second, about 60 companies a minute with the extras off, and stops early with "shared API allowance busy" if the allowance is nearly used up. With your own key it runs at 1.8 requests per second, about 100 companies a minute. Filing history, officers and PSC are off by default and add one request each per company. A run lasts at most 20 minutes.
  • With officers or PSC turned on, it returns names, roles, dates and nature of control only, never dates of birth, nationality or addresses, even though the API returns some of them.
  • US$2.00 per 1,000 companies plus US$0.0005 per run start (down to US$1.40 per 1,000 on paid Apify plans). The Companies House API itself is free. Apify's free plan includes US$5 of usage a month, about 2,500 companies.
  • Every row has a sourceUrl to the company's page on the official register.

It is not affiliated with or endorsed by Companies House.

FAQ

Is the Companies House API free?

Yes. The key is free and the REST API has no usage charge. The limit is 600 requests per 5 minutes per key.

Why does the Companies House API return 401?

The request did not carry a key it accepts. The most common causes: the key sent as a Bearer token, no Authorization header at all, or a typo in the key. The key must be the Basic auth username with an empty password. If the key is in the password slot instead, the API returns 400.

Why do I get 404 for a company that exists?

The number is probably not in the 8-character format. Pad all-digit numbers with leading zeros (445790 → 00445790) and use an uppercase prefix (SC083026, not sc083026). Both short and lowercase forms returned 404 in my tests.

Can I search Companies House by company name through the API?

Yes, with GET /search/companies?q=<name>. Results are ranked by relevance, so the first hit is not always the company you mean. Use the returned company_number with GET /company/{number} for the full profile.

Should I put the API key in my Python script?

No. Read it from an environment variable (os.environ["COMPANIES_HOUSE_API_KEY"]) or a secrets store, and keep it out of version control and out of browser JavaScript.

Do you look companies up by number, or do you start from a name and have to pick the right match?

Disclosure: I built the Apify Actor mentioned in this post.