update endpoints

This commit is contained in:
Cynthia Foxwell 2025-11-19 15:14:57 -07:00
parent a7d056a550
commit 116652c2a5
No known key found for this signature in database
3 changed files with 44 additions and 35 deletions

View File

@ -12,9 +12,9 @@ proc getGraphUser*(username: string): Future[User] {.async.} =
headers.add("Referer", """https://x.com/$1""" % username)
let
variables = """{"screen_name":"$1"}""" % username
fieldToggles = """{"withAuxiliaryUserLabels":true}"""
params = {"variables": variables, "features": gqlFeatures, "fieldToggles": fieldToggles}
variables = """{"screen_name":"$1","withGrokTranslatedBio":false}""" % username
fieldToggles = """{"withPayments":false,"withAuxiliaryUserLabels":true}"""
params = {"variables": variables, "features": userFeatures, "fieldToggles": fieldToggles}
js = await fetch(graphUser ? params, Api.userScreenName, headers)
result = parseGraphUser(js)
@ -26,7 +26,7 @@ proc getGraphUserById*(id: string): Future[User] {.async.} =
let
variables = """{"userId":"$1"}""" % id
params = {"variables": variables, "features": gqlFeatures}
params = {"variables": variables, "features": userFeatures}
js = await fetch(graphUserById ? params, Api.userRestId, headers)
result = parseGraphUser(js)

View File

@ -34,16 +34,17 @@ proc genParams*(pars: openArray[(string, string)] = @[]; cursor="";
proc genHeaders*(): HttpHeaders =
let
t = getTime()
ffVersion = floor(124 + ((t.toUnix() / 1000) - 1710892800) / 2419200)
ffVersion = floor(124 + (t.toUnix() - 1710892800) / 2419200)
result = newHttpHeaders({
"connection": "keep-alive",
"authorization": auth,
"content-type": "application/json",
"accept-encoding": "gzip",
"accept-language": "en-US,en;q=0.5",
"accept": "*/*",
"Connection": "keep-alive",
"Authorization": auth,
"Content-Type": "application/json",
"Accept-Encoding": "gzip",
"Accept-Language": "en-US,en;q=0.5",
"Accept": "*/*",
"DNT": "1",
"Host": "x.com",
"Origin": "https://x.com/",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin",

View File

@ -15,23 +15,23 @@ const
timelineApi = api / "2/timeline"
graphql = api / "graphql"
graphUser* = graphql / "ZHSN3WlvahPKVvUxVQbg1A/UserByScreenName"
graphUserById* = graphql / "XIpMDIi_YoVzXeoON-cfAQ/UserByRestId"
graphUserTweets* = graphql / "oRJs8SLCRNRbQzuZG93_oA/UserTweets"
graphUserTweetsAndReplies* = graphql / "kkaJ0Mf34PZVarrxzLihjg/UserTweetsAndReplies"
graphUserMedia* = graphql / "36oKqyQ7E_9CmtONGjJRsA/UserMedia"
graphTweet* = graphql / "YVyS4SfwYW7Uw5qwy0mQCA/TweetDetail"
graphTweetResult* = graphql / "tCVRZ3WCvoj0BVO7BKnL-Q/TweetResultByRestId"
graphUser* = graphql / "-oaLodhGbbnzJBACb1kk2Q/UserByScreenName"
graphUserById* = graphql / "Bbaot8ySMtJD7K2t01gW7A/UserByRestId"
graphUserTweets* = graphql / "lZRf8IC-GTuGxDwcsHW8aw/UserTweets"
graphUserTweetsAndReplies* = graphql / "gXCeOBFsTOuimuCl1qXimg/UserTweetsAndReplies"
graphUserMedia* = graphql / "1D04dx9H2pseMQAbMjXTvQ/UserMedia"
graphTweet* = graphql / "6QzqakNMdh_YzBAR9SYPkQ/TweetDetail"
graphTweetResult* = graphql / "kLXoXTloWpv9d2FSXRg-Tg/TweetResultByRestId"
graphTweetHistory* = graphql / "WT7HhrzWulh4yudKJaR10Q/TweetEditHistory"
graphSearchTimeline* = graphql / "7r8ibjHuK3MWUyzkzHNMYQ/SearchTimeline"
graphSearchTimeline* = graphql / "bshMIjqDk8LTXTq4w91WKw/SearchTimeline"
graphListById* = graphql / "iTpgCtbdxrsJfyx0cFjHqg/ListByRestId"
graphListBySlug* = graphql / "-kmqNvm5Y-cVrfvBy6docg/ListBySlug"
graphListMembers* = graphql / "P4NpVZDqUD_7MEM84L-8nw/ListMembers"
graphListTweets* = graphql / "BbGLL1ZfMibdFNWlk7a0Pw/ListTimeline"
graphFavoriters* = graphql / "mDc_nU8xGv0cLRWtTaIEug/Favoriters"
graphRetweeters* = graphql / "RCR9gqwYD1NEgi9FWzA50A/Retweeters"
graphFollowers* = graphql / "Efm7xwLreAw77q2Fq7rX-Q/Followers"
graphFollowing* = graphql / "e0UtTAwQqgLKBllQxMgVxQ/Following"
graphFollowers* = graphql / "SCu9fVIlCUm-BM8-tL5pkQ/Followers"
graphFollowing* = graphql / "S5xUN9s2v4xk50KWGGvyvQ/Following"
favorites* = graphql / "eSSNbhECHHWWALkkQq-YTA/Likes"
timelineParams* = {
@ -51,7 +51,14 @@ const
}.toSeq
gqlFeatures* = """{
"rweb_video_screen_enabled": false,
"profile_label_improvements_pcf_label_in_post_enabled": true,
"responsive_web_profile_redirect_enabled": false,
"rweb_tipjar_consumption_enabled": true,
"verified_phone_label_enabled": false,
"creator_subscriptions_tweet_preview_api_enabled": true,
"responsive_web_graphql_timeline_navigation_enabled": true,
"responsive_web_graphql_skip_user_profile_image_extensions_enabled": false,
"premium_content_api_read_enabled": false,
"communities_web_enable_tweet_community_results_fetch": true,
"c9s_tweet_anatomy_moderator_badge_enabled": true,
@ -74,26 +81,26 @@ const
"tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled": true,
"longform_notetweets_rich_text_read_enabled": true,
"longform_notetweets_inline_media_enabled": true,
"payments_enabled": false,
"responsive_web_grok_image_annotation_enabled": true,
"responsive_web_grok_imagine_annotation_enabled": true,
"responsive_web_grok_community_note_auto_translation_is_enabled": false,
"responsive_web_enhance_cards_enabled": false
}""".replace(" ", "").replace("\n", "")
userFeatures* = """{
"hidden_profile_subscriptions_enabled": true,
"profile_label_improvements_pcf_label_in_post_enabled": true,
"responsive_web_profile_redirect_enabled": false,
"rweb_tipjar_consumption_enabled": true,
"verified_phone_label_enabled": false,
"responsive_web_grok_image_annotation_enabled": true,
"responsive_web_grok_imagine_annotation_enabled": true,
"responsive_web_grok_community_note_auto_translation_is_enabled": false,
"responsive_web_graphql_skip_user_profile_image_extensions_enabled": false,
"responsive_web_graphql_timeline_navigation_enabled": true,
"responsive_web_enhance_cards_enabled": false,
"rweb_client_transaction_id_enabled": false,
"rweb_xp_forwarded_for_enabled": false,
"subscriptions_verification_info_is_identity_verified_enabled": true,
"subscriptions_verification_info_verified_since_enabled": true,
"highlights_tweets_tab_ui_enabled": true,
"hidden_profile_subscriptions_enabled": true,
"subscriptions_verification_info_is_identity_verified_enabled": true,
"subscriptions_feature_can_gift_premium": false,
"responsive_web_twitter_article_notes_tab_enabled": true,
"rweb_video_screen_enabled": true
"subscriptions_feature_can_gift_premium": true,
"creator_subscriptions_tweet_preview_api_enabled": true,
"responsive_web_graphql_skip_user_profile_image_extensions_enabled": false,
"responsive_web_graphql_timeline_navigation_enabled": true
}""".replace(" ", "").replace("\n", "")
tweetVariables* = """{
@ -141,7 +148,8 @@ const
"userId": "$1",
$2
"count": 20,
"includePromotedContent": false
"includePromotedContent": false,
"withGrokTranslatedBio": false
}""".replace(" ", "").replace("\n", "")
userMediaVariables* = """{