How to create my first Rest/API to integrate all search features

I am extremely overwhelmed with so much information and trying to figure it out on my own. Therefore |I am going to try to get help and see how i can make it happen.

I am trying to use the REST/API feature to add the companies search to my WordPress website.

I have already created the API key and now have to connect it to my WordPress website.

Please advise how to engage the information as i am not sure what else to do

Welcome.

I recommend you take your time. This API is pretty simple as they go, but it has numerous quirks *.

If you’re using WordPress presumably you are comfortable doing some PHP programming? If not then skip to the end.

Initially I would not try to get things running in PHP - instead I’d:

a) Work out what pages (links) you would go through and what information you’d enter to get the information using Companies House search site online. The API basically mirrors the design of that (indeed some of the URLs are almost identical).

b) Then work through making the requests to the API using something very basic / simple and interactive like the curl command - so you can see exactly what information you’re sending and what you get back.

If you didn’t already I would start by reading Companies House’s own documentation. First the introduction (alas this quite isn’t as clear / up to date as it might be) and then the API documentation. Beware that the latter may not be quite correct.

Perhaps also look at the unofficial documentation complied here.

If you have specific queries try searching this forum (use the magnifying glass icon, usually at the top right of the site). If after that you’re stuck, try posting a specific query (saying what you tried, what you were expecting, what happened etc. - more information is better but do not post your API Key or other secrets here!)

Finally: there are some companies available who will provide services around Companies House, or programmers who can help for a fee.

Good luck

  • I can’t think of any public API I’ve used which doesn’t have quirks, was completely documented, or that didn’t have differences between documentation and the actual API (or at the very least a confusing mix of out-of-date and current documentation…)

Thank you so much for your response. I will look into the information shared.

I am capable in PHP - and want to work on the wordpress side - i still have not been able to connect and get a response from the API - but i am working on it.

Can’t connect and get a response from the API?
You’ll get some response though not necessarily anything in the http body (check the returned http response code, or if using curl - again recommended - turn on verbose with the -v flag).

Common problems involve the initial CH setup:

  • not choosing “live” when you register you app. Short - just use live ones.
  • not registering your IP address or host name / not registering the correct IP address (e.g. if you’re on some hosting service this may be variable).
  • using a local host e.g. on a development workstation without the workaround for your IP address (search the forum for “localhost workaround” or see the thread below:

).

Common problems authenticating:

  • misunderstanding the http Basic standard, or how the API key relates to the http username and password (it’s the username, and the password is empty / blank), or how your library / client / tool implements this.

Other quirks:

  • currently some - but not all - Companies House API URLs will not work if there is a trailing slash “/” at the end of the URL.

Of course PHP has a wrapper around curl (with its own quirks). Then there’s the popular PSR-7 standard for http libraries e.g. Guzzle. Unfortunately the Companies House OpenAPI specification needs some manual work to allow you to e.g. automatically generate client code from it. (I also find that this doesn’t always help understand an API - and now you’ve got two things to understand…)