Search companies pagination problem if items_per_page=1

I am using GET https://api.company-information.service.gov.uk/search/companies.

If I run (for example, with items_per_page=2):

curl -uMY_API_KEY: "https://api.company-information.service.gov.uk/search/companies/?start_index=0&items_per_page=2&q=MINISTRY%20OF%20SOUND%20RECORDINGS%20LIMITED"

it yields (as expected) (edited):

{"items":[{ ... "title":"MINISTRY OF SOUND RECORDINGS LIMITED", ...}, {... "title":"MINISTRY OF SOUND LIMITED", ...}], "start_index":0, "total_results":97059, "page_number":1, "kind":"search#companies", "items_per_page":2}

However, if I run (the same call, except with items_per_page=1):

curl -uMY_API_KEY: "https://api.company-information.service.gov.uk/search/companies/?start_index=0&items_per_page=1&q=MINISTRY%20OF%20SOUND%20RECORDINGS%20LIMITED"

it yields (edited):

{"items":[{ ... "title":"MINISTRY OF SOUND LIMITED", ... }], "page_number":2, "items_per_page":1, "start_index":1, "total_results":97059, "kind":"search#companies"}

Note that the returned start_index is 1, even though it was passed in as 0, and the page_number is 2, not 1 as would be expected (given that the start_index was passed in as 0). On the face of it, this appears to be a bug in the API.

Same bug as noted here I think. (Non-“data issue” bugs are not fixed very quickly):

Workaround - if setting items_per_page set it to > 1. In general it makes sense to set both items_per_page and start_index.

For general behaviour of pagination (when working) see the last comment on this thread:

1 Like

@voracityemail thank you. Yes, it seems to be the same bug that you identified in November 2018.