feat: add sendTweet with media upload support - #193
Conversation
…on#24) - remove deprecation warning by using `JestConfigWithTsJest` - allow jest to use local .env file by providing `dotenv` to config. - make email variable optional when running auth test. - fixed fetchTweets returning an empty array lol :]
The following properties on the `Tweet` interface are now `false` as default. This most likely fixes any method that relies on checking these. - isQuoted - isRetweet - isReply - isPin - sensitiveContent Tweet tests have been updated accordingly.
Updates the SearchTimeline GraphQL endpoint to fix 404 errors when using fetchSearchTweets and related search functionality. Changes: - Update query ID from bshMIjqDk8LTXTq4w91WKw to nK1dw4oV3k4w5TdtcAdSww - Add missing feature flags required by Twitter's API: - responsive_web_graphql_exclude_directive_enabled - tweetypie_unmention_optimization_enabled - responsive_web_media_download_video_enabled - rweb_lists_timeline_redesign_enabled Fixes the-convocation#77 Related to the-convocation#137, the-convocation#165 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Removed NPM_AUTH_TOKEN from publish step environment variables.
- Updates all GraphQL endpoints - Overhauls login flow to deal with anti-bot mechanisms - Adds a preflight request to the request lifecycle - Properly implements the JS instrumentation subtask - Castle token spoofing - Updates a bunch of old API endpoints
…n#186) - Update 9 of 10 endpoint query IDs extracted from Twitter's current main.js bundle (Feb 20, 2026) - Sync feature flags to match current frontend expectations - Remove deprecated flags: creator_subscriptions_quote_tweet_preview, graphql_exclude_directive, tweetypie_unmention_optimization, media_download_video, lists_timeline_redesign - Fixes the-convocation#185 (SearchTimeline returning 404)
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
Adds scraper.sendTweet() for posting tweets via the CreateTweet GraphQL mutation, including image/video media upload through the chunked upload API. - Add mutationEndpoints (CreateTweet queryId + URL) to api-data.ts - Implement uploadMedia() with chunked video upload + polling and simple image upload paths - Implement sendTweet() returning Tweet | null; injects __typename when absent from the CreateTweet API response to satisfy the parser - Add optional x-client-transaction-id generation to avoid 226 errors - Expose sendTweet on the Scraper class and export MediaData from _module.ts - Add unit + opt-in integration tests in tweet-mutations.test.ts
|
The |
4c67ddd to
203f49f
Compare
Summary
src/api-data.ts— addsmutationEndpoints.CreateTweet(current queryId +x.comURL)src/tweets.ts— implementsuploadMedia()(chunked video + simple image) andsendTweet()returningTweet | nullsrc/scraper.ts— exposessendTweet()as a public method on theScraperclasssrc/_module.ts— exports the newMediaDatatypesrc/tweet-mutations.test.ts— unit tests + opt-in integration tests for the mutationKey details
CreateTweetGraphQL mutation (queryId: S1qcGUn68_U0lDKdMlYSGg) viaPOST x.com/i/api/graphql/…__typename: 'Tweet'on the response when absent (the CreateTweet API omits it) so the existing parser can handle itx-client-transaction-idwhen theexperimental.xClientTransactionIdoption is enabled, to avoid Twitter's 226 "looks automated" errorsMediaDataaccepts{ data: Buffer, mediaType: string }; videos use the chunked INIT/APPEND/FINALIZE flow with status pollingTest plan
npm test— all unit tests passTWITTER_*env vars and runnpx jest tweet-mutations --testNamePattern=integration