Requested 10k bars, but only returns 404 with next_page_token

https://data.alpaca.markets/v2/stocks/SPY/bars?start=2024-01-01T00:00:00.000Z&timeframe=30Min&limit=10000

I have an example request there, and each page returns 404 candles, and a next page token. I can paginate and get all the bars, but isn’t the limit supposed to be 10,000?

Hey :wave:

The documentation of the limit parameter specifically highlights that this can happen:

The maximum number of data points to return in the response page.
The API may return less, even if there are more available data points in the requested interval.

If you’re interested, the reason behind this is that the 30Min bars you’re requesting are actually constructed from minute bars (as described in the last paragraph of this FAQ). To fulfil your request, the server needs to read the minute bars from the database. 10 000 30Min bars can potentially need 300 000 minute bars to be read, which could cause the response to be slow. To avoid this, the server returns after reading (more than) 10 000 minute bars and constructing the 404 30Min bars from them.

As you said, you can then paginate to get the rest of the bars, all with acceptable response time.