Best practice to ping Companies House service to check up time.
Is there any API built to ping Companies House?
No, there is no ‘PING’ available through the API.
Just as a follow up to this.
There is a way to call the service to ensure it is available, this can be done by curling the
API health check endpoint. An example of how this can be done is:
curl -vvv -k -X GET -H “Authorisation” -H “Cache-Control: no-cache” -H “Postman token” https://api.companieshouse.gov.uk/healthcheck
This should return a 200 status.
I think @KDJones command above should read:
curl -v -k -X GET -H "Authorisation" -H "Cache-Control: no-cache" -H "Postman token" https://api.companieshouse.gov.uk/healthcheck
…that’s just a single “-v” flag for (–verbose) not “-vvv” as the original had it. I think I still got a response using the original line however…
This produces a lot of output, a shorter response would be using:
curl -I -k -X GET -H "Authorisation" -H "Cache-Control: no-cache" -H "Postman token" https://api.companieshouse.gov.uk/healthcheck
That gives me:
HTTP/1.1 200 OK
Date: Fri, 02 Feb 2018 10:22:47 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 0
Connection: keep-alive
Server: CompaniesHouse
So as @KDJones says this returns a 200 status.
I don’t think you need curl specifically - although it or an equivalent are likely to be available as a library in your chosen language. If you want to use it from the command line as a test (free) see the curl homepage or the curl documentation.
I’ve only tested this on the command line. I haven’t yet seen any other status (good!) to verify what exactly happens when the servers are down. However it seems general and simple enough for me now.
@muhammadadeel118 (sigh) It’s not my business and we’re all busy people but if you have a problem it’s almost always helpful to give more info rather than less. E.g. rather than “it’s not working” something like “I want to achieve {overall goal}. I’m trying to do this by {CH endpoint / method / algorithm / command}. The steps I took were {List of what you did with any response / errors you received}. {If something was unexpected:} I expected {x} to happen but {y} happened.”
These sites explain it better than I can:
Short, self-contained correct example (http://sscce.org/)
How to write a good bug report (http://noverse.com/blog/2012/06/how-to-write-a-good-bug-report/)