Search X
x.com and twitter.com block ordinary fetches, and web search does not return the posts. Read one known tweet or profile from the public FixTweet API. Search, find accounts, and read threads with Grok's X tools.
Which path
The user handed you one status URL, one status id, or one handle, and wants that tweet or that profile:
curl FixTweet. No key. Do not start Grok for this.
# A post. The id is the number in /status/<id>, including /i/web/status/<id>.
curl -fsS "https://api.fxtwitter.com/status/<id>"
# A profile. The handle without @.
curl -fsS "https://api.fxtwitter.com/<screen_name>"
The body is JSON. A post is under .tweet (text, author, created_at, likes, replies, media, community_note). A profile is under .user (name, screen_name, description, followers, website). If .tweet or .user is missing, read .message and stop. This returns that one object. It does not search, and it does not return replies.
You already have x_keyword_search, x_semantic_search, x_user_search, and x_thread_fetch:
Call them. Do not start another grok process.
You do not:
Run the command below. One question is one process. This needs the grok CLI, installed and logged in. FixTweet cannot search.
Which tool
Pick from the question. Do not run every tool every time.
| Question | Tool |
|---|---|
| Words, a phrase, a handle, a date, a filter | x_keyword_search |
| The wording is unknown and meaning is the only handle | x_semantic_search, then drop posts whose text is about something else |
| Who is this account, or what is their handle | x_user_search, then from:handle if you need their posts |
| What was said around this post | x_thread_fetch with the post id |
x_keyword_search is X advanced search. Spaces are AND, OR must be uppercase, quotes are an exact phrase, -term excludes, from: and to: and @ select people, since: and until: are dates, filter: selects replies, quotes, links, or media, min_faves: sets a floor. mode is Latest or Top. Latest is what is happening. Top is what got attention. One call returns at most 10 posts. Narrow the query, or page with since:, until:, or max_id:, instead of asking for more than 10.
x_semantic_search matches meaning, so near-miss topics come back as hits. A date range and a username list are filters on that call. Keep a post only when its text answers the question.
x_user_search takes a name or a handle, not a post query. x_thread_fetch takes a post id and returns the parents and the replies.
Command
grok -p "$(cat <<'EOF'
Answer this from X. Do not use the web. Do not write files.
<question>
Use only x_keyword_search, x_semantic_search, x_user_search, and x_thread_fetch.
Pick the tool that matches the question. Do not run every tool.
Keyword search is X advanced search: spaces are AND, OR is uppercase, quotes are an exact phrase, -term excludes, from: and since: and filter: and min_faves: work. mode is Latest or Top. One call returns at most 10 posts.
Semantic search matches meaning and returns nearby topics. Keep a post only when its text answers the question.
User search finds accounts. Thread fetch takes a post id and returns the conversation.
For each post you use: author name, @handle, date, https://x.com/<handle>/status/<id>, and the text. If nothing matched, say so.
EOF
)" \
--cwd /tmp \
--always-approve \
--max-turns 12 \
--disallowed-tools "write,search_replace,run_terminal_cmd,task,web_search,web_fetch" \
--output-format plain
Replace <question> with the actual ask. Leave the rest of the prompt as written.
Why these flags:
--always-approveis required. Headless mode has no one to click Allow, so without it the process waits until it is killed.--cwd /tmpkeeps the search off the repo you are in. Grok would otherwise load that project's rules and could treat the repo as its workspace.--max-turns 12covers a few searches and a thread. Raise it only when the run stops because it hit the turn cap.- Do not pass
--tools x_keyword_search,.... Those are the names the model calls, and--toolsdoes not recognize them. Grok then warns and leaves every other tool available, so the flag does not sandbox anything. The denylist is what actually removes shell, edits, subagents, and the web.
Give the process several minutes. Read stdout. If stderr says a denylist name is unknown, drop that one name and rerun. An unknown denylist entry removes nothing.
How to report
Answer the question that was asked. Cite the status URL, the handle, and the date for every post you rely on. Leave out posts that do not match. If the tool summary and the post text disagree, trust the post text. No matching posts is a result, not a failed command.