Companies House provide REST API, which lets you retrieve information about limited companies in UK. In this article, will use python script to get data from Companies House data using REST API.
Prerequisites
We need to register with Companies House to access REST API. Follow the steps below:
- Create a developer account
- Create an application
- Go to application overview and create REST API key
- Use REST API key in your Python script
Python script
import requests
import json
import sys
url = "https://api.companieshouse.gov.uk/company/{}"
query = sys.argv[1]
api_key = "type your REST API Key"
response = requests.get(url.format(query),auth=(api_key,''))
json_search_result = response.text
search_result = json.JSONDecoder().decode(json_search_result)
print(search_result)
print(search_result.keys())
python getCompanyDetails.py 13466392
Output
{'accounts': {'accounting_reference_date': {'day': '30', 'month': '06'}, 'last_accounts': {'type': 'null'}, 'next_made_up_to': '2022-06-30', 'overdue': False, 'next_accounts': {'period_end_on': '2022-06-30', 'due_on': '2023-03-20', 'overdue': False, 'period_start_on': '2021-06-20'}, 'next_due': '2023-03-20'}, 'company_name': 'PHOENIX THE FEARLESS LTD', 'company_number': '13466392', 'company_status': 'active', 'confirmation_statement': {'next_made_up_to': '2022-06-19', 'next_due': '2022-07-03', 'overdue': False}, 'date_of_creation': '2021-06-20', 'etag': 'b76860612020754b6c527decfc1342d11879b979', 'has_charges': False, 'has_insolvency_history': False, 'has_super_secure_pscs': False, 'jurisdiction': 'england-wales', 'links': {'self': '/company/13466392', 'filing_history': '/company/13466392/filing-history', 'persons_with_significant_control': '/company/13466392/persons-with-significant-control', 'officers': '/company/13466392/officers'}, 'registered_office_address': {'country': 'United Kingdom', 'postal_code': 'WA1 1RG', 'address_line_1': '320 Firecrest Court Centre Park', 'locality': 'Warrington'}, 'registered_office_is_in_dispute': False, 'sic_codes': ['62020'], 'type': 'ltd', 'undeliverable_registered_office_address': False, 'can_file': True}
dict_keys(['accounts', 'company_name', 'company_number', 'company_status', 'confirmation_statement', 'date_of_creation', 'etag', 'has_charges', 'has_insolvency_history', 'has_super_secure_pscs', 'jurisdiction', 'links', 'registered_office_address', 'registered_office_is_in_dispute', 'sic_codes', 'type', 'undeliverable_registered_office_address', 'can_file'])
Company profile
Get the basic company information using REST API
Request
GET https://api.company-information.service.gov.uk/company/{companyNumber}