API for Excel - Wrong Credentials?

Hi,
I have found an excel document from somebody online which has the ability to enter the company number and it will extract useful information for me such as company status etc.

The problem I am having is the API key, I’ve created numerous now but I cant get Excel to have the correct login credentials to fetch it for me.

Any help would be gratefully appreciated.

Thanks

1 Like

As always when using a public API it is worth starting as simply as possible so you can see exactly what is (or isn’t) happening. That should allow you to eliminate other confusing factors e.g. someone else’s interface to this system.

I recommend using something basic such as curl (which most systems have). First issue the most basic command e.g. request company profile to return some data and see what happens and what errors you get, if any.

curl -u YOUR_API-KEY: https://api.company-information.service.gov.uk/company/03977902

(note the “:” at the end of the API key - this is because the syntax is username:password - but for Companies House they designed it so there is no password, the username is the API key which is treated as the password).

If all works you should get back some JSON string with company information.

If the API key is incorrect / unknown to Companies House you’ll get something like:

{“error”:“Invalid Authorization”,“type”:“ch:service”}

Turn on verbose mode (the -v flag) so you can see all the communication and look for what errors you get. In the above case you’ll get a 401 http status also.

Obviously a 404 means that nothing was found - that suggests you’ve got something wrong with the syntax / the company number. 429 means companies house thinks you’ve exceeded their rate limit / have otherwise blocked you - in that case you’ll need to re-post and ask them to unblock!

Now if you search this forum (the magnifying glass icon at top right) you’ll find various articles about the various errors you may get and how to get round them. Companies House require you to register the host URL / IP address you’re calling Companies House from. It also seems that there may be problems using the “sandbox” system rather than the live environment.

Good luck.

1 Like