Persistant 401 errors

I’m experiencing persistent 401 errors whilst trying to access the API. The error is also exhibited on the Developer Hub console.

I’ve had this problem in the past, typically I get queries through for a period followed by a period in which I get 401 errors.

So far this morning I have had only 401 responses - I’m doing a 1 minute interval retry and I’m currently up to 54 - my code will give up in 6 minutes.

We cannot see any problems with the service.
Could you provide some more details please.
What are you doing? Accessing company details? Officer details?

On the Developer test console here:

I’m just doing a simple search for a company, IBM, for example.

My code is accessing the disqualified director information, by first searching for the index (GET /search/disqualified-officers?q=A*) and then accessing the detail page (GET /disqualified-officers/natural/qD4b6dQDkuZOcTX5NWRmBdRtmis).

My code is written in Python using the requests library, it is following the rate limit on a per request basis (i.e. 0.5 seconds between requests, rather than 600 requests per 5 minutes).

Both console and code are giving me 401 unauthorized errors.

I reported the same problem a couple of weeks ago (via email) and it was resolved with the core explanation:

We did identify an issue around the time you were getting 401 errors, one of our accounts sites was not responding quickly enough due to load. We have increased of the accounts part of the service so this should not happen again.

How do I know if this is why I am getting nothing but 401 today? Is there a status available anywhere?

You can check that the service as a whole is up using:

curl -I -k -X GET -H "Authorisation" -H "Cache-Control: no-cache" -H "Postman token"

…which it is at the moment:

HTTP/1.1 200 OK
Date: Sun, 27 Feb 2022 16:42:20 GMT
Content-Length: 0
Connection: keep-alive
Server: CompaniesHouse

That doesn’t prove very much though.
Generally if there were any major issues here would be a good place to check.
I don’t think there are at the moment.
It’s most likely there’s an issue with your API key, or you’re trying to access from somewhere (IP / domain) that you haven’t registered with Companies House, or possibly you’re not using the “live” token (I’m not so sure about this part - we joined up before that functionality came in. Just search on the forum, there are questions answered about that.)