Rishikant181 / Rettiwt-API

A CLI tool and an API for fetching data from Twitter for free!
https://rishikant181.github.io/Rettiwt-API/
MIT License
305 stars 31 forks source link

Add ability to fetch data from Spaces #416

Closed rolivencia closed 5 months ago

rolivencia commented 5 months ago

With some additional work, it would be possible to support fetching data from Spaces and Spaces recordings, which would allow to cover more surface area from the API.

Looking at the network tab when navigating through Spaces recordings, it seems the data is fetched similarly to Tweet details. With minimal adjustments, we should be able to support the feature.

Rishikant181 commented 5 months ago

I never knew about spaces. Where can I access it from the web app?

rolivencia commented 5 months ago

Here's the URL of a Space recording: https://twitter.com/ladrondesabado/status/1736920785162240151

And here's the cURL request for that resource, minus the token:

curl "https://twitter.com/i/api/graphql/s2tz6GAie-O1tdZx873PLA/AudioSpaceById?variables=^%^7B^%^22id^%^22^%^3A^%^221OdKrjnmmQVKX^%^22^%^2C^%^22isMetatagsQuery^%^22^%^3Afalse^%^2C^%^22withReplays^%^22^%^3Atrue^%^2C^%^22withListeners^%^22^%^3Atrue^%^7D&features=^%^7B^%^22spaces_2022_h2_spaces_communities^%^22^%^3Atrue^%^2C^%^22spaces_2022_h2_clipping^%^22^%^3Atrue^%^2C^%^22creator_subscriptions_tweet_preview_api_enabled^%^22^%^3Atrue^%^2C^%^22responsive_web_graphql_exclude_directive_enabled^%^22^%^3Atrue^%^2C^%^22verified_phone_label_enabled^%^22^%^3Afalse^%^2C^%^22c9s_tweet_anatomy_moderator_badge_enabled^%^22^%^3Atrue^%^2C^%^22responsive_web_graphql_skip_user_profile_image_extensions_enabled^%^22^%^3Afalse^%^2C^%^22tweetypie_unmention_optimization_enabled^%^22^%^3Atrue^%^2C^%^22responsive_web_edit_tweet_api_enabled^%^22^%^3Atrue^%^2C^%^22graphql_is_translatable_rweb_tweet_is_translatable_enabled^%^22^%^3Atrue^%^2C^%^22view_counts_everywhere_api_enabled^%^22^%^3Atrue^%^2C^%^22longform_notetweets_consumption_enabled^%^22^%^3Atrue^%^2C^%^22responsive_web_twitter_article_tweet_consumption_enabled^%^22^%^3Afalse^%^2C^%^22tweet_awards_web_tipping_enabled^%^22^%^3Afalse^%^2C^%^22freedom_of_speech_not_reach_fetch_enabled^%^22^%^3Atrue^%^2C^%^22standardized_nudges_misinfo^%^22^%^3Atrue^%^2C^%^22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled^%^22^%^3Atrue^%^2C^%^22rweb_video_timestamps_enabled^%^22^%^3Atrue^%^2C^%^22longform_notetweets_rich_text_read_enabled^%^22^%^3Atrue^%^2C^%^22longform_notetweets_inline_media_enabled^%^22^%^3Atrue^%^2C^%^22responsive_web_media_download_video_enabled^%^22^%^3Afalse^%^2C^%^22responsive_web_graphql_timeline_navigation_enabled^%^22^%^3Atrue^%^2C^%^22responsive_web_enhance_cards_enabled^%^22^%^3Afalse^%^7D" ^
  -H "authority: twitter.com" ^
  -H "accept: */*" ^
  -H "accept-language: es-419,es;q=0.9,es-ES;q=0.8,en;q=0.7,en-GB;q=0.6,en-US;q=0.5" ^
  -H "authorization: Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs^%^3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA" ^
  -H "content-type: application/json" ^
  -H "cookie: [FILL_WITH_COOKIES_HERE] ^
  -H "referer: https://twitter.com/ladrondesabado/status/1736920785162240151" ^
  -H "sec-ch-ua: ^\^"Not_A Brand^\^";v=^\^"8^\^", ^\^"Chromium^\^";v=^\^"120^\^", ^\^"Microsoft Edge^\^";v=^\^"120^\^"" ^
  -H "sec-ch-ua-mobile: ?0" ^
  -H "sec-ch-ua-platform: ^\^"Windows^\^"" ^
  -H "sec-fetch-dest: empty" ^
  -H "sec-fetch-mode: cors" ^
  -H "sec-fetch-site: same-origin" ^
  -H "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0" ^
  -H "x-client-transaction-id: QCUqLciSr5e66fuKqUqc+SkhVT9Wr2kbIze9GPIi+CbtYiuZ4/35lr3M7VF6eI/ifQyaCkGd5RYsTqY1HoVctCWRaj4RQQ" ^
  -H "x-client-uuid: cb4ca763-7c29-48fd-acf0-58654481d7c9" ^
  -H "x-csrf-token: [FILL_WITH_TOKEN_HERE]" ^
  -H "x-twitter-active-user: yes" ^
  -H "x-twitter-auth-type: OAuth2Session" ^
  -H "x-twitter-client-language: es" ^
  --compressed

By adding a new entry to EResourceType and handling the built Request properly we may be able to support the feature. If possible, I'd like to work on it.

rolivencia commented 5 months ago

After a second look, maybe this issue fits best in the rettiwt-core repo.

Rishikant181 commented 5 months ago

@rolivencia Yes indeed. However, these changes will eventually arrive here, although it will be a while before they do.