Send an X (Twitter) DM from an AI agent
Automatically send an X (Twitter) DM from an AI agent on x.com. Send a direct message to an X user, addressed by handle. Returns the recipient, a sent flag and conversation_id. Delivery is confirmed by X's own send mutation returning HTTP 200, not by reading the DOM. conversation_id is null for a brand-new DM and for a DM to your own account (the compose dialog renders no existing-conversation cell to read the recipient id from) — a null there does not mean the send failed. A fresh session with no stored encryption keys may need the 4-digit E2E pin.
Input
handle requiredRecipient's X handle without @
message requiredMessage text to send
pin optional4-digit E2E passcode — required only if X shows the Enter Passcode screen (fresh session without stored encryption keys). Omit otherwise.
Output
sent requiredrecipient requiredconversation_id optionalDerived as "<recipientId>-<ownId>", matching get_inbox's format. Null when the compose dialog offered no existing-conversation cell to read the recipient id from — the case for a brand-new DM and for a DM to your own account — so null here does not mean the send failed. Confirm delivery with get_messages if you need it.
FAQ
X (Twitter) search unofficial API: search tweets, no API key
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)
Fetch a tweet by URL — the focal post plus the surrounding conversation. Returns `tweet` (the focal post; null if deleted/tombstoned) and `replies[]`, which holds every other tweet on the conversation page: both the focal's ancestors (the thread above it, present when the focal is itself a reply; each has `in_reply_to` null or pointing above the focal) and the replies below it (`in_reply_to` points at the focal or a sibling reply). Use `in_reply_to` to tell ancestors from replies and rebuild the thread — the array is not filtered to descendants of the focal. Each entry is a canonical tweet record: id, url, author {id, handle, name}, text, created_at, lang, likes, retweets, replies, quotes, bookmarks, views, is_retweet, is_quote, in_reply_to {id, author_handle}. Scrolls the main thread until `count` is met (then complete=false — more may exist) or it drains (complete=true). Replies behind a "Show more replies"/hidden/probable-spam cursor are not expanded, so even complete=true is a floor, not a guarantee every nested reply was seen.
X (Twitter) posts unofficial API: export a user's tweets and stats
An unofficial X (Twitter) API for a user's posts: export an account's latest tweets with their views, likes, reposts, replies, quotes and bookmarks as data, in one call, without the X API. For the owner-only analytics of each post (impressions, engagements), run get_post_analytics on its id. Get a user's latest posts by handle (x.com/<handle>, the Posts tab), newest first: their own tweets and self-threads, without replies (see get_user_replies) or reposts (see get_user_reposts). Works signed in or signed out. Signed in, it reads the full Posts tab up to count. Signed out, X only shows visitors its few most recent posts, so it returns that short preview and fewer than count is expected; each post's source field says which one you got. Returns per tweet: id, url, text, created_at, lang, likes, retweets, replies, quotes, views, bookmarks, is_retweet, is_quote, source.
