api request_error ai_generated true

HTTP 400: Pagination token expired or invalid

ID: api/rest-api-pagination-token-expired

Also available as: JSON · Markdown · 中文
88%Fix Rate
83%Confidence
1Evidence
2024-03-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
REST API v3.0 active
cursor-based pagination active
Twitter API v2 active

Root Cause

The pagination cursor or token used in the API request has expired or was generated for a different query context, causing the server to reject it.

generic

中文

API 请求中使用的分页游标或令牌已过期,或为不同查询上下文生成,导致服务器拒绝。

Official Documentation

https://developer.twitter.com/en/docs/twitter-api/pagination

Workarounds

  1. 90% success Restart pagination from the beginning by omitting the cursor parameter.
    Restart pagination from the beginning by omitting the cursor parameter.
  2. 85% success Cache the initial request and re-fetch from scratch if token expires.
    Cache the initial request and re-fetch from scratch if token expires.

中文步骤

  1. Restart pagination from the beginning by omitting the cursor parameter.
  2. Cache the initial request and re-fetch from scratch if token expires.

Dead Ends

Common approaches that don't work:

  1. 90% fail

    The token is already expired; waiting will not revive it.

  2. 95% fail

    Tokens are opaque and server-generated; manual modification breaks integrity checks.

  3. 60% fail

    Some APIs do not support offset pagination; this may not be an option.