Simple python script to access Companies House API

Hi all, Im not a developer but Im trying to work out how to access Companies house using a python script. Should something like this work?

import requests
url = 'https://api.companieshouse.gov.uk/search/companies/"01591116'
headers = {'my_api_key': '***********my_api_key**********'}
r = requests.get(url, headers=headers)
print r.text

Im getting this: {"error":"Invalid authorization header","type":"ch:service"}

I found it :slight_smile:

import requests

r = requests.get('https://api.companieshouse.gov.uk/company/00002065', auth=('xxxxxxxxxxxxxxxxxxxxxxxxxxx', ''))
print(r.text)
4 Likes