Cursor mismatch
CURSOR_MISMATCH comes with HTTP 400. The cursor is valid, but your request is not the search it was made for: the sort order or the filters changed.
What it means
A cursor belongs to one search. The API remembers the sort order and a fingerprint of the filters. On the next page it compares them with your request. If they differ, the cursor cannot continue that search, and the API answers with this error.
Only cursor, limit and include may change between pages. Everything else must be sent again exactly as on the first page.
Example response
The first page was requested with "query": "ticker:NVDA". The second page uses its cursor with a different query:
cURL
curl -X POST 'https://api.finlight.me/v3/articles/search' \
-H 'Content-Type: application/json' \
-H 'X-API-KEY: YOUR_API_KEY' \
-H 'X-Request-Id: req-123' \
-d '{ "query": "ticker:AMD", "limit": 1, "cursor": "eyJ2IjoxLCJr..." }'
Response (400): filters changed
{
"type": "https://docs.finlight.me/errors/cursor-mismatch",
"title": "Cursor mismatch",
"status": 400,
"detail": "The cursor was issued for a different set of filters. Start a new search without a cursor.",
"code": "CURSOR_MISMATCH",
"requestId": "req-123",
"errors": [
{ "field": "cursor", "issue": "The cursor was issued for a different set of filters. Start a new search without a cursor." }
]
}
When the sort order changed, the detail names both orders:
Response (400): sort order changed
{
"type": "https://docs.finlight.me/errors/cursor-mismatch",
"title": "Cursor mismatch",
"status": 400,
"detail": "The cursor was issued for sort order 'publishedAt:desc', the request asks for 'publishedAt:asc'.",
"code": "CURSOR_MISMATCH",
"requestId": "req-123",
"errors": [
{ "field": "cursor", "issue": "The cursor was issued for sort order 'publishedAt:desc', the request asks for 'publishedAt:asc'." }
]
}
Common causes
- A different
orderByororderon a later page. - A changed filter, such as a different
query,tickersorsources. - Adding
toon later pages. A common mistake is to settoto the current time on every page. The first page withouttoand the second page withtoare different searches. Leavetoout, or keep the exact value from the first page. - Adding a default value. An absent field is not the same as its default. If the first page had no
languages, then"languages": ["en"]on the second page is a different search, even though["en"]is the default. OnlyorderByandorderare compared with their defaults filled in, so adding"order": "desc"on page 2 is fine. - A different spelling of a value. Values are not normalized:
["EN"]is not["en"].
The order of values in a list does not matter, and neither do repeated values. ["de", "en"] and ["en", "de"] are the same filter.
How to fix
- Store the request body of the first page.
- For every later page, send that body again and only add or change
cursor,limitorinclude. - If you really want different filters or a different order, start a new search without
cursor.
The client libraries do this for you: searchAll (Python: search_all) freezes the request when you call it and only adds the cursor on later pages. See Pagination.
Retry
Do not retry. The same request fails again. The client libraries never retry it, and searchAll stops with this error.
In the SDKs
| Language | Error |
|---|---|
| TypeScript, Python, Ruby | CursorMismatchError |
| .NET, Java, PHP | CursorMismatchException |
| Go | *finlight.APIError with APIKind == finlight.APIKindCursorMismatch |
| Rust | Error::Api with api_kind() == ApiErrorKind::CursorMismatch |
Let the library page for you
for await (const article of client.articles.searchAll({ query: 'ticker:NVDA', limit: 100 }, { maxPages: 5 })) {
console.log(article.id, article.title)
}