Skip to main content
POST
Twitter sentiment analysis API for X posts with AI
2 credits per analyzed post · All plans from $0.00012/credit · Supports guest paid reads
Sentiment analysis reads each post with AI and answers 3 questions about it. The endpoint is POST /api/v1/x/analysis/sentiment.
The snippets build 1 row per analyzed post and print the totals. They do not print the full response.

Pick the posts to analyze

Send tweetIds, texts, or a search, never more than 1. Sending none, or more than 1, returns 400 invalid_input. A search combines every search field you send into 1 X search. queryType sets the order, Latest or Top. For more posts than 1 call returns, send the same search again with cursor set to next_cursor. Stop when has_next_page is false.
Your own texts come back with the IDs text:1, text:2, and so on.

Read the sentiment answers

results[].answers holds each decision by question ID. Store it beside the post. Upbeat deals, ads, and giveaways that state no opinion count as neutral. intensity judges wording, emphasis, and emoji, not engagement counts. It can have decimals, such as 1.4 between measured and emphatic. sarcasm is high when the literal wording contradicts the intended attitude. results[].analysis.answers adds the confidence of each answer and the probability of each category or level. Use it to set your own thresholds.

Judge the attitude toward a brand

Name the brand, person, or product in analysis.targets, with its aliases. The AI then judges the attitude toward that target. Without targets, it judges the attitude toward the post’s main subject. analysisSummary.targets counts each target’s mentions and sentiment categories. It also lists the most engaged posts per category.

Track sentiment over time

analysisSummary.questions.sentiment counts posts per category. shares holds each category’s share of posts, and engagementShares its share of engagement. Store both per run to chart a trend. To read 1 day, send sinceTime and untilTime with the search. Send username to follow 1 account’s posts.

Compare with an earlier answer

Send the results of an earlier call as baseline to see what changed. Each row in the new results gets monitor, and analysisSummary.monitor counts the posts per status. The comparison costs nothing extra.
A baseline row needs the post’s id, or tweet.id, and its answers. Send whole result rows when you have them. Their monitor carries the settings’ fingerprint, so rows from other settings show as not_comparable. A decision counts as changed only when the new answer clearly leaves the old one, so near ties between calls stay unchanged. Keep analysis the same between calls for comparable answers.

Budget the analysis

Each analyzed post costs 2 credits. Each text in texts costs the same. Posts in unanalyzed cost nothing. When credits cover fewer posts than you asked for, fewer come back. The posts left over appear in unanalyzed with insufficient_credits. If credits cover no post, the call returns 402 insufficient_credits.

Ask your own questions

Send analysis.questions to ask up to 8 questions of your own. They replace the 3 sentiment questions, and the price stays the same. A choice picks 1 category, a score picks 1 level, and a probability answers yes or no. Write question IDs and category names in lower case without hyphens, such as feature_request.

Body

string[]
Up to 100 post IDs or post URLs, such as x.com/nasa/status/20. A post named twice is analyzed once. Send tweetIds, texts, or a search, not more than 1.
string
X search to analyze, with the operators of Search Tweets.
string
Analyze 1 account’s posts. Send a handle, with or without @, or a profile URL.
string
Analyze a public List’s posts. Send its ID or URL.
string
Analyze the quotes of 1 post. Send its ID or URL.
string
Analyze the replies in 1 post’s conversation. Send its ID or URL.
string
Inclusive start of the search, such as 2026-09-25T00:00:00Z. Unix seconds also work. A time without an offset is UTC.
string
Exclusive end of the search. Unix seconds also work. A time without an offset is UTC.
string
Search order: Latest or Top. Defaults to Latest.
integer
Maximum posts to analyze from the search. Range: 1-100. Defaults to 20. Credits can return fewer.
string
The next_cursor of the page before. Send the same search with it.
string[]
Up to 100 texts of your own, such as drafts. Each must contain words. Reads nothing from X.
object[]
Rows of an earlier answer to compare with, up to 10,000, such as its results. Each needs the post’s id, or tweet.id, and its answers. Each new result’s monitor says whether the post is new, changed, or unchanged. The comparison costs nothing extra.
object
Optional settings. Leave it out to ask the route’s own questions.

Headers

string
Full account API key. An OAuth bearer token also works.
string
Send Bearer xq_your_guest_key_here for an active paid_reads guest key.
string
required
Must be application/json. The body can be up to 256 KB.

Response

200 OK

object[]
Each analyzed post with its answers. Each row costs 2 credits.
object[]
Each post without an analysis. These cost nothing.
object
Totals of the answers across the analyzed posts.
boolean
Whether the search has more posts. Always false for tweetIds and texts.
string
Send it as cursor with the same search for the next page. Empty when there is none.

400 Invalid input

The body names no posts, names more than 1 source, or has an invalid field. The message says what to send instead. The request costs nothing.

401 Unauthenticated

Anonymous requests get WWW-Authenticate: Bearer and a guest wallet checkout action. This is not a Payment challenge.
Missing or invalid API key. Check the x-api-key header value.

402 Payment required

Full account keys can receive no_subscription, subscription_inactive, no_credits, or insufficient_credits with account payment options. Guest keys receive only the guest top-up action. The failed request creates no checkout. Ask the user to confirm before calling any checkout or top-up route.

403 Protected account

A search that needs a protected author returns this. Choose a public account. The request costs nothing.

502 X API unavailable

The read service returned an error. Retry after a short delay.

503 Service busy

Xquik is busy. Wait for the Retry-After header, then send the request again. The request costs nothing.

429 Rate limit exceeded

You exceeded your tier rate limit. Wait for the Retry-After header before retrying.

424 Dependency failed

The normalized v1 response contract can return 424 when the read service is unavailable.

Twitter sentiment analysis API questions

How do I analyze the sentiment of tweets?

Send a search in query, or post IDs in tweetIds, to this endpoint. Each row in results holds the post and its sentiment, intensity, and sarcasm answers.

Can I measure the sentiment toward my brand?

Yes. Name the brand in analysis.targets, with its product names as aliases. The AI judges the attitude toward the brand, and analysisSummary.targets counts its mentions.

Does it detect sarcasm?

Yes. sarcasm is the probability, from 0 to 1, that the literal wording contradicts the intended attitude. Read it beside sentiment before you act on a post.

Can I check a draft before I post it?

Yes. Send the draft in texts. Xquik reads nothing from X, and each text costs 2 credits.

How much does sentiment analysis cost?

Each analyzed post costs 2 credits. Posts in unanalyzed and refused requests cost nothing.

Does this replace X’s official API?

No. This page documents Xquik, an independent third-party service. It does not document X’s official API.
Next steps. Market signals reads stock and crypto stances, or Search Tweets previews the posts a query returns.