Skip to content

Instantly share code, notes, and snippets.

@cmj
Last active June 19, 2024 12:21
Show Gist options
  • Save cmj/4c1753195ec42a7a62a6cdff995f89ae to your computer and use it in GitHub Desktop.
Save cmj/4c1753195ec42a7a62a6cdff995f89ae to your computer and use it in GitHub Desktop.
Twitter timelines without account
#!/bin/bash
# 2024-06-15 - Old Twitter api endpoints are up again.
# 2024-06-18 - Old Twitter api with guest token access are open (no account needed)
user=$1
if [ -z $user ]; then echo "$0 username"; exit; fi
count=5
bearer_token="AAAAAAAAAAAAAAAAAAAAAFQODgEAAAAAVHTp76lzh3rFzcHbmHVvQxYYpTw%3DckAlMINMjmCwxUcaXbAN4XqJVdgMJaHqNOFgPMK0zN1qLqLQCF"
id=$(curl -s "https://api.twitter.com/1.1/users/lookup.json?screen_name=${user}" -H "Authorization: Bearer ${bearer_token}" | jq -r '.[].id')
guest_token=$(curl -s -XPOST https://api.twitter.com/1.1/guest/activate.json -H "Authorization: Bearer ${bearer_token}" | jq -r '.guest_token')
## old-api basic timeline
#curl -s "https://api.twitter.com/1.1/timeline/user.json?id=44196397&count=${count}" \
# -H "Authorization: Bearer ${bearer_token}" \
# -H "x-guest-token: ${guest_token}" |
# jq -C | bat # or fx
#exit
## old-api search (still broken)
#curl -s -v "https://api.twitter.com/1.1/search/universal.json?q=elonmusk" \
# -H "Authorization: Bearer ${bearer_token}" \
# -H "x-guest-token: ${guest_token}"
#exit
## graphql, tweets & replies
variables="{\"rest_id\":\"${id}\",\"count\":${count}}"
features='{"android_graphql_skip_api_media_color_palette":false,"blue_business_profile_image_shape_enabled":false,"creator_subscriptions_subscription_count_enabled":false,"creator_subscriptions_tweet_preview_api_enabled":true,"freedom_of_speech_not_reach_fetch_enabled":false,"graphql_is_translatable_rweb_tweet_is_translatable_enabled":false,"hidden_profile_likes_enabled":false,"highlights_tweets_tab_ui_enabled":false,"interactive_text_enabled":false,"longform_notetweets_consumption_enabled":true,"longform_notetweets_inline_media_enabled":false,"longform_notetweets_richtext_consumption_enabled":true,"longform_notetweets_rich_text_read_enabled":false,"responsive_web_edit_tweet_api_enabled":false,"responsive_web_enhance_cards_enabled":false,"responsive_web_graphql_exclude_directive_enabled":true,"responsive_web_graphql_skip_user_profile_image_extensions_enabled":false,"responsive_web_graphql_timeline_navigation_enabled":false,"responsive_web_media_download_video_enabled":false,"responsive_web_text_conversations_enabled":false,"responsive_web_twitter_article_tweet_consumption_enabled":false,"responsive_web_twitter_blue_verified_badge_is_enabled":true,"rweb_lists_timeline_redesign_enabled":true,"spaces_2022_h2_clipping":true,"spaces_2022_h2_spaces_communities":true,"standardized_nudges_misinfo":false,"subscriptions_verification_info_enabled":true,"subscriptions_verification_info_reason_enabled":true,"subscriptions_verification_info_verified_since_enabled":true,"super_follow_badge_privacy_enabled":false,"super_follow_exclusive_tweet_notifications_enabled":false,"super_follow_tweet_api_enabled":false,"super_follow_user_api_enabled":false,"tweet_awards_web_tipping_enabled":false,"tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled":false,"tweetypie_unmention_optimization_enabled":false,"unified_cards_ad_metadata_container_dynamic_card_content_query_enabled":false,"verified_phone_label_enabled":false,"vibe_api_enabled":false,"view_counts_everywhere_api_enabled":false}'
curl -s -G "https://api.twitter.com/graphql/8IS8MaO-2EN6GZZZb8jF0g/UserWithProfileTweetsAndRepliesQueryV2" \
--data-urlencode "variables=${variables}" \
--data-urlencode "features=${features}" \
-H "Authorization: Bearer ${bearer_token}" \
-H "x-guest-token: ${guest_token}" |
jq -C | bat #fx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment