You didn’t mention you were passing in any term to search for. If you check the Search Companies documentation you’ll see that that’s a q
parameter. So (in curl) you’d have (I’ve edited this just to show one entry):
curl -u MY_API_KEY_HERE: "https://api.company-information.service.gov.uk/search/companies?q=asda&items_per_page=4&start_index=0"
Returning:
{
"total_results": 121,
"items": [
{
"kind": "searchresults#company",
"description": "14217167 - Incorporated on 5 July 2022",
"company_status": "active",
"links": { "self": "/company/14217167" },
"snippet": "",
"address_snippet": "173 St. Dunstans Hill, Cheam, Sutton, England, SM1 2LR",
"address": {
"address_line_1": "St. Dunstans Hill",
"postal_code": "SM1 2LR",
"premises": "173",
"address_line_2": "Cheam",
"country": "England",
"locality": "Sutton"
},
"company_type": "ltd",
"matches": {
"title": [ 1, 4 ],
"snippet": [ ]
},
"company_number": "14217167",
"title": "ASDA LIMITED",
"description_identifier": [ "incorporated-on" ],
"date_of_creation": "2022-07-05"
},
... (another 3 company objects)
],
"kind": "search#companies",
"page_number": 1,
"items_per_page": 4,
"start_index": 0
}
It makes sense to pass both items_per_page
and start_index
- note that start_index
is zero-based.
Using javascript fetch it may be convenient to use the URLSearchParams object to format the URL parameters for you:
const url = "https://api.company-information.service.gov.uk/search/companies?" + ( new UrlSearchParams( {q: "asda", "items_per_page": "4", "start_index": "0" } ) ).toString();