Search URL? Well, before you do that I would start with the following, probably the simplest query for this API (use curl directly from the shell / command line if you can as that provides instant feedback without any conflicting factors like your code not doing what you think…)
curl -u YOURAPIKEY: "https://api.company-information.service.gov.uk/company/00502851"
Note the “:” after your API key (because curl expects a http Basic username and password - Companies House made this so the API key is the username and there is no password…)
That should get you some text (JSON data).
If not, try getting more information - add the “-v” flag (for verbose):
curl -v -u YOURAPIKEY: "https://api.company-information.service.gov.uk/company/00502851"
The basic search URL is https://api.company-information.service.gov.uk/search/companies
- to which you add parameters. Because this is a URL don’t forget to URL-encode the parameter values (PHP provides a simple query builder which is nicer for multiple parameters):
curl -u YOURAPIKEY: "https://api.company-information.service.gov.uk/search/companies?q=tescos"
… or to limit the number of results (several parts of the Companies House API implement a “paging” interface to get a subset of a larger data set):
curl -u YOURAPIKEY: "https://api.company-information.service.gov.uk/search/companies?q=tescos&items_per_page=4&start_index=0"
Certainly the first time I worked with any “remote procedures” / external interface it was more challenging. You’re far more reliant on someone else’s documentation and “try it and see”.
However working from basic principles it’s not much different from working with someone else’s code (apart from you don’t get to see that or modify it): try not to “assume”, add tests to check the data as well as your assumptions. Even where something is documented - with external APIs it seems the documentation is far more … variable, and may be inconsistent e.g. parts may be current, parts older.
If you run into a snag check the Companies House documentation but ALSO search this forum, there are several … features of the API.
Also for this particular data set the data can be pretty wild. That is by its nature - legally Companies House is mostly required to record - mostly verbatim - the information that the public at large supply. So expect omissions, duplications, mistakes, misunderstandings etc. Indeed some frankly bogus information - though you can help by reporting on anything you think is verifiably not correct. Plus data covers over a century - “fixed” things have changed in that time (laws, countries, nationalities …)