Unable to get all filing history

no matter how i fix the ‘items_per_page’ and ‘start_index’, i only get latest 25 filings…,

is there any method that i could get all the historical filings?

Welcome / 안녕하세요!

Companies House has - for some endpoints, including the filing history - a “paged” system. This means you may need to call the endpoint several times, changing the start_index parameter each time. So you get data in n pages of items_per_page results.

Have you tried setting start_index to 0, making a request, then setting start_index to the next multiple of items_per_page?

Making the requests to Companies House via curl, I can write eg.:

curl -u MY_API_KEY_HERE: "https://api.company-information.service.gov.uk/company/04366849/filing-history?items_per_page=4&start_index=0"

… and get back (edited version):

    "items": [ { four results } ]

And then:

curl -u MY_API_KEY_HERE: "https://api.company-information.service.gov.uk/company/04366849/filing-history?items_per_page=4&start_index=4"

… and get the next four results etc.

Setting items_per_page to 50 seems to work. If you choose much larger numbers at some point you may find that Companies House don’t return all the results at once. I would always count the number of results you receive. Then declare that to be the items per page, check to see if you have all results (compare your total count with total_count) and if not finished set start_index to the current number of results you have and run the query again.

Two notes in passing:

  1. I believe Companies House encourage use of api.company-information.service.gov.uk now rather than api.companieshouse.gov.uk

  2. There was (is?) a bug if you set items_per_page to 1 so avoid that unless you’ve checked it works (search this forum for info).

Hope this helps.