Skip to content

fix: switch SearchTimeline from GET to POST to fix 404 errors#191

Merged
karashiiro merged 1 commit intothe-convocation:mainfrom
HaruHunab1320:fix/search-post-method
Apr 1, 2026
Merged

fix: switch SearchTimeline from GET to POST to fix 404 errors#191
karashiiro merged 1 commit intothe-convocation:mainfrom
HaruHunab1320:fix/search-post-method

Conversation

@HaruHunab1320
Copy link
Copy Markdown
Contributor

Summary

Twitter has started blocking GET requests to the SearchTimeline GraphQL endpoint, returning 404 for all search queries. The Python twikit library independently discovered the same fix in d60/twikit#412 on March 29, 2026.

This PR switches the search endpoint from GET to POST with a JSON body, which resolves the 404 errors.

Changes

  • api.ts: Add optional body parameter to requestApi(). When provided with a POST request, sets content-type: application/json and stringifies the body.
  • api-data.ts: Add toRequestBody() method to ApiRequest class, converting variables/features/fieldToggles to a JSON object (instead of URL query params).
  • search.ts: Change getSearchTimeline from 'GET' to 'POST', passing the request body via toRequestBody() instead of the URL via toRequestUrl().

Test plan

  • Verified with authenticated session — searchTweets() and fetchSearchTweets() now return results that previously gave 404
  • User timeline fetching (getTweets) continues to work as before
  • No changes to any other endpoints

Fixes #188

Twitter has started blocking GET requests to the SearchTimeline
GraphQL endpoint, returning 404 for all search queries. This change
switches the search endpoint to use POST with a JSON body instead
of URL query parameters, matching the fix discovered in twikit#412.

Changes:
- api.ts: Add optional `body` parameter to requestApi(), set
  content-type header and stringify body for POST requests
- api-data.ts: Add toRequestBody() method to ApiRequest class
  for converting variables/features/fieldToggles to JSON body
- search.ts: Change getSearchTimeline from GET to POST, pass
  request body via toRequestBody() instead of URL via toRequestUrl()

Fixes the-convocation#188
@karashiiro karashiiro merged commit cb2aa73 into the-convocation:main Apr 1, 2026
2 of 4 checks passed
@HaruHunab1320 HaruHunab1320 deleted the fix/search-post-method branch April 1, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Response status 404 on searchTwets

2 participants