Is there a bug using start_index parameter?

The output Json seems to be the same regardless of what is specified in start_index?
Happens in API call and via the web

Have you an example? This seems to be working as usual for me. There are a couple of things to note about start_index and search in general to watch for but it’s not clear what your issue is.

I’m guessing the most likely one that you have is something like you have to use a multiple of number of items_per_page - e.g. if you alter start_index the “paging” mechanism seems to expect you to specify both that and items_per_page. I believe “start_index” starts from zero. It seems that one should be a multiple of the other, as demonstrated at the end of the following thread:

Otherwise this works for me - just run the following (via curl, setting items_per_page to a very low value to show behaviour. I’ve also cropped out most of the detail and rearranged order of fields for clarity):

curl -uMY_API_KEY: "https://api.companieshouse.gov.uk/search/companies?q=buy&items_per_page=3&start_index=0"

{
    "total_results": 3658,
    "page_number": 1,
    "items_per_page": 3,
    "kind": "search#companies",
    "start_index": 0,
    "items": [
        {
            "company_number": "03880920",
            "title": "BUY LIMITED"
        },
        {
            "company_number": "11926789",
            "title": "BEAGLE BUTTON LIMITED"
        },
        {
            "company_number": "11511248",
            "title": "BUY A BANGER LTD"
        }
    ]
}

curl -uMY_API_KEY:  "https://api.companieshouse.gov.uk/search/companies?q=buy&items_per_page=3&start_index=3"

{
    "start_index": 3,
    "items_per_page": 3,
    "total_results": 3658,
    "kind": "search#companies",
    "page_number": 2,
    "items": [
        {
            "company_number": "12515686",
            "title": "BUY A BANGER LIMITED"
        },
        {
            "company_number": "08828361",
            "title": "BUY A BARCODE LTD"
        },
        {
            "title": "BUY A BARGAIN (U.K) LIMITED",
            "company_number": "11775856"
        }
    ]
 
}

For reference - other issues around search and start_index / items_per_page (I’ve just checked and they’re still current issues):

Bug when setting items_per_page to 1:

Using search you can’t go higher than a certain value of start_index (this is limited by design)

Other “paging” issues:

Filing history returns start_index as a string, not number:

Not quite a bug but an inconsistency - items_per_page and start_index not returned in chargeList resource:

I get the issue when doing a search for “Prism”

You can reproduce it at the bottom of the following page

GET /search/companies?q=Prism
GET /search/companies?q=Prism&start_index=1
GET /search/companies?q=Prism&start_index=2

All appear to retrieve the same results

Yes, this is the “feature” I mentioned at the top of my post.

… you have to use a multiple of number of items_per_page - e.g. if you alter start_index the “paging” mechanism seems to expect you to specify both that and items_per_page.

Just include a suitable items_per_page and make your start_index a multiple of that (inc. zero). This is - briefly - described in documentation and more fully elsewhere on this forum.

I’ve no idea why anyone would want a single item at a specific start index if you were just searching. However due to the other “feature” noted above you can’t get that by doing e.g.:

start_index=3&items_per_page=1

There is the “paging” mechanism and you have to play along with that. The following would be logical but doesn’t work - “page” is ignored:

curl -uMY_API_KEY: "https://api.companieshouse.gov.uk/search/companies?q=Prism&items_per_page=2&page=3"

As you’ve said if you don’t include an items_per_page Companies House will likely ignore your start_index / round it down to the nearest multiple of the items_per_page they’ll default to. (For reference the default is currently 20). They might do something else entirely - anyway just specify items_per_page. Do check the value of this / number of results in the items arrray in case you requested a larger number than they returned.

Using your example - and the lowest limit for items_per_page which works - I can pick what I like:

curl -uMY_API_KEY: "https://api.companieshouse.gov.uk/search/companies?q=Prism&start_index=2&items_per_page=2"
{
"start_index":2, "items_per_page":2, "page_number":2, "total_results":1018, ...

If I wanted more results I’d just keep incrementing start_index by 2.

In practice we normally try for 20, 50 or even 100 items per page depending on what we’re doing.