Read your X (Twitter) For You timeline
Automatically read your X (Twitter) For You timeline on x.com. Get tweets from your personal For You home feed — the timeline as shown: top-level posts plus the replies and quote-tweets X threads in. Returns per tweet: id, url, author {id, handle, name}, text, created_at, lang, likes, retweets, replies, quotes, bookmarks, views, is_retweet, is_quote, plus ref objects quoted_tweet/in_reply_to (each {id, author_handle}, null when N/A). For a repost, the tweet is the reposted original as X shows it: id, author, text and counts are the original's, is_retweet is true, and reposted_by/reposted_at say who reposted it and when. in_reply_to != null is the reply test. Count is capped by how far the feed paginates before throttling. When the browser is signed out of X, the run fails with a signed-out error asking you to sign in to x.com.
Input
count optionalHow many to return. Without it, the script returns the first page X shows (often 20 to 40). With it, the script loads more until it has count, reaches the end, or X stops loading; complete says whether it reached the end.
Output
count requiredNumber of tweets returned. 0 is a valid answer.
tweets requiredcomplete requiredTrue when X showed the end of the feed and every one it sent is returned. False when there may be more: count was reached, X stopped loading, or no count was given and the first page is not the end.
FAQ
Search X (Twitter) posts
Search X (Twitter) for tweets with every X search operator, from the Top tab (a ranked sample, the default) or the Latest tab (chronological), picked by the tab arg. Returns per tweet a canonical record: id, url, author {id, handle, name}, text, created_at, lang, likes, retweets, replies, quotes, bookmarks, views, is_retweet, is_quote, plus followers (the author's follower count, a search-only enrichment), and the top-level query and count. Top is a ranked sample, not exhaustive.
Get a tweet and its replies on X (Twitter)
Get a tweet on X (Twitter) by URL, with the conversation around it: `tweet` (the post itself) and `replies` (every other post of its conversation on the page: the thread above it when it is a reply, and the replies below; use in_reply_to to rebuild the thread). Each post has id, url, author, text, created_at, lang, counts, in_reply_to and quoted_tweet. With count, it loads more replies until it has count or X reaches the end. complete is true only when X reached the end and left no folded replies (Show replies, hidden or probable-spam sections), which this script does not open. A deleted or unavailable tweet is an error. Requires being signed in to X.
Get X (Twitter) user profile
Look up an X (Twitter) user's profile by handle. Returns handle, user_id, name, bio, location, website, joined, followers_count, following_count, is_verified, is_self, is_following, follows_you. Counts are exact integers. bio and website carry the real destination URLs, with X's shortlinks resolved. is_following is null on your own profile. Any of is_self, is_following, follows_you and is_verified is null when X does not say. Requires being signed in to X; a missing or suspended account is an error that says which.
