I am trying to search for companies in a location and just printing to the screen at this stage suing the following code, However I only get 20 responses. Why is that?
import requests
Define API endpoint and query parameters
endpoint = “https://api.company-information.service.gov.uk/advanced-search/companies”
params = {
“location”: “Suffolk”,
“company_status”: “Active”,
“items_per_page”: “100”, # Specify the number of results per page
“start_index”: “0”, # Specify the starting index for results
}
Make API request
headers = {
“Authorization”: “API_KEY”
}
response = requests.get(endpoint, params=params, headers=headers)
Check if the request was successful
if response.status_code == 200:
# Extract company numbers from the response
companies = response.json().get(“items”, [])
company_numbers = [company[“company_number”] for company in companies]
print(“Status code:”, response.status_code)
print(“Company Numbers in Suffolk:”)
print(company_numbers)
else:
print(“Failed to retrieve data. Status code:”, response.status_code)