How to Get Twitter Analytics Data Through an API (2026 Guide)
Key Takeaway: To get Twitter/X analytics data through an API, you have three options: the native X Analytics dashboard (Premium subscribers only), the official X API v2 with public_metrics and organic_metrics fields, or a third-party API provider. Your choice depends on whether you need metrics for your own account, any public account, or advertising campaigns.
If you've searched for "twitter analytics API," you've probably already discovered that the answer isn't straightforward. The phrase means different things depending on what you're trying to do -- pull engagement stats for your own tweets, monitor a competitor's account, build a reporting dashboard, or analyze trends at scale.
In this guide, we'll break down every option and show how tools like Sorsa API make it practical to pull engagement metrics for any public account without OAuth complexity or unpredictable costs.
The analytics landscape on X (formerly Twitter) has shifted dramatically since the 2023 pricing overhaul. The old tier-based system is gone. Academic Research access is nearly impossible to get. The native dashboard is locked behind a paywall. Having worked with Twitter's API since the v1.1 days, I've helped dozens of teams navigate these changes -- and the options in 2026 are both more flexible and more confusing than ever.
Here's what actually works.
Contents:
- What "Twitter Analytics API" Actually Means
- Which Metrics Can You Actually Get Through an API?
- How to Pull Tweet Analytics with Python
- Calculating Engagement Rate from API Data
- Tracking Competitors and Brand Mentions
- What Happened to Academic Research Access?
- FAQ
- Getting Started
What "Twitter Analytics API" Actually Means (Three Different Things)
Most confusion around this topic comes from conflating three entirely separate systems. They serve different audiences, return different data, and have different access requirements.
X Analytics Dashboard (Your Own Account Only)
The built-in analytics dashboard at x.com/analytics shows impressions, engagement rate, follower growth, and top tweets -- but only for your own account. Since 2023, this dashboard is available exclusively to Premium (verified) subscribers. Free accounts can no longer access it at all.
There's no API behind this dashboard. No export. No automation. If you want to programmatically access your own account's analytics, you need one of the two options below.
X API v2 Public and Organic Metrics (Programmatic Access)
The official X API v2 provides tweet and user data through REST endpoints. For analytics purposes, there are two relevant metric categories:
public_metrics -- available for any public tweet via a simple Bearer Token. Returns likes, retweets, replies, quotes, impressions (labeled impression_count), and bookmarks. This is what most developers actually need.
organic_metrics and non_public_metrics -- available only for tweets authored by the authenticated user. Requires OAuth 2.0 user context authentication. Returns a more detailed breakdown including organic impression counts and video playback percentages.
The X API now uses pay-per-use pricing: reading a post costs $0.005 per resource. No subscriptions, no monthly caps -- you buy credits upfront and they're deducted as you go.
X Ads API Analytics (Advertisers Only)
The X Ads API is a completely separate system designed for advertisers. It tracks campaign-level metrics like promoted impressions, CPM, click-through rates, conversions, and audience segmentation by demographics.
If you're not running paid campaigns on X, the Ads API is irrelevant to your use case. The rest of this guide focuses on the first two categories -- getting public tweet and user metrics through code.
Which Metrics Can You Actually Get Through an API?
Here's a direct comparison of what each source gives you. This is the table I wish existed when I started helping clients migrate away from the old API tiers.
| Metric | X Analytics Dashboard | X API v2 public_metrics | X API v2 organic_metrics | Sorsa API |
|---|---|---|---|---|
| Likes | Own account only | Any public tweet | Own tweets only | Any public tweet |
| Retweets | Own account only | Any public tweet | Own tweets only | Any public tweet |
| Replies | Own account only | Any public tweet | Own tweets only | Any public tweet |
| Quotes | No | Any public tweet | No | Any public tweet |
| Views | Own account only | Any public tweet (as impression_count) | Own tweets only | Any public tweet |
| Bookmarks | No | Any public tweet | No | Any public tweet |
| Follower count | Own account only | Any public user | n/a | Any public user |
A few things stand out. The X API v2 public_metrics fields are genuinely useful -- you can get core engagement metrics for any public tweet with a Bearer Token. The limitation is cost and structure: at $0.005 per post read, pulling metrics for 10,000 tweets costs $50. And each tweet lookup is a separate resource charge.
Sorsa API returns all of these metrics for any public tweet -- with one structural advantage that matters for analytics workflows. Every tweet response includes the full author profile (followers, following, tweet count, bio, verified status) at no extra cost. That's one request returning 20 tweets with complete engagement data plus author context, instead of separate calls for tweets and users.
Disclosure: Sorsa API is our product. We've aimed to keep this comparison factual, but recommend testing any solution with your own workload.
How to Pull Tweet Analytics with Python
Let's get concrete. Here are two working approaches to fetch tweet metrics programmatically.
Option 1: Official X API v2
To get public metrics for a specific tweet, make an authenticated GET request with the tweet.fields=public_metrics parameter:
import requests
import os
bearer_token = os.environ.get("X_BEARER_TOKEN")
tweet_id = "1882368585664626774"
url = f"https://api.x.com/2/tweets/{tweet_id}"
params = {"tweet.fields": "public_metrics,created_at"}
headers = {"Authorization": f"Bearer {bearer_token}"}
response = requests.get(url, headers=headers, params=params)
if response.status_code == 200:
tweet = response.json()["data"]
metrics = tweet["public_metrics"]
print(f"Likes: {metrics['like_count']}")
print(f"Retweets: {metrics['retweet_count']}")
print(f"Replies: {metrics['reply_count']}")
print(f"Views: {metrics['impression_count']}")
print(f"Bookmarks: {metrics['bookmark_count']}")
else:
print(f"Error: {response.status_code} - {response.text}")
This works well for individual tweets. The response looks like:
{
"data": {
"id": "1882368585664626774",
"text": "Announcing our new API features...",
"created_at": "2026-01-15T10:30:00.000Z",
"public_metrics": {
"retweet_count": 142,
"reply_count": 38,
"like_count": 891,
"quote_count": 23,
"bookmark_count": 67,
"impression_count": 284500
}
}
}
Cost: $0.005 per tweet. Getting metrics for a user's last 100 tweets requires multiple paginated requests, each charged per resource returned.
Authentication: Bearer Token for public_metrics (any tweet). OAuth 2.0 user context for organic_metrics (own tweets only). See the X API docs for setup.
Option 2: Sorsa API
With Sorsa API, a single request returns up to 20 tweets with all engagement metrics and the author's full profile:
import requests
api_key = "YOUR_SORSA_API_KEY"
url = "https://api.sorsa.io/v3/user-tweets"
payload = {"username": "elonmusk"}
headers = {"ApiKey": api_key}
response = requests.post(url, json=payload, headers=headers)
if response.status_code == 200:
data = response.json()
for tweet in data["tweets"]:
engagement = (
tweet["likes_count"]
+ tweet["retweet_count"]
+ tweet["reply_count"]
+ tweet["quote_count"]
)
views = tweet["view_count"]
rate = (engagement / views * 100) if views > 0 else 0
print(f"Tweet: {tweet['full_text'][:60]}...")
print(f" Views: {views:,} | Likes: {tweet['likes_count']:,} "
f"| RT: {tweet['retweet_count']:,} | Engagement rate: {rate:.2f}%")
print()
else:
print(f"Error: {response.status_code}")
The response includes everything you need for analytics in a single call:
{
"tweets": [
{
"id": "1882368585664626774",
"full_text": "Announcing our new API features...",
"created_at": "2026-01-15T10:30:00Z",
"likes_count": 891,
"retweet_count": 142,
"reply_count": 38,
"quote_count": 23,
"view_count": 284500,
"bookmark_count": 67,
"user": {
"username": "example",
"followers_count": 52400,
"verified": true
}
}
],
"next_cursor": "ASDJKHFJWQE123Q"
}
Cost: $0.00199 per request on the Pro plan. That's 20 tweets with full metrics for under two-tenths of a cent -- roughly $0.0001 per tweet.
Authentication: Single API key in the header. No OAuth, no app approval, no callback URLs. Get a key here.
Calculating Engagement Rate from API Data
Raw metrics are useful. Engagement rate makes them actionable.
The standard formula for calculating engagement rate from API data:
Engagement Rate = (Likes + Retweets + Replies + Quotes) / Views x 100
Here's a practical Python function that works with batch tweet data:
def calculate_engagement_rate(tweet):
"""Calculate engagement rate from tweet metrics."""
interactions = (
tweet.get("likes_count", 0)
+ tweet.get("retweet_count", 0)
+ tweet.get("reply_count", 0)
+ tweet.get("quote_count", 0)
)
views = tweet.get("view_count", 0)
if views == 0:
return 0.0
return round(interactions / views * 100, 4)
A worked example: a tweet with 891 likes, 142 retweets, 38 replies, 23 quotes, and 284,500 views has an engagement rate of (891 + 142 + 38 + 23) / 284,500 * 100 = 0.38%. That's a solid rate for an account with over 50K followers -- anything above 0.2% is generally healthy for large accounts.
One caveat: the native X Analytics dashboard calculates engagement differently. It includes all interactions (link clicks, profile clicks, media expansions) in the numerator, which inflates the number. The formula above uses only publicly available metrics, so your numbers will be lower than what the dashboard shows -- but they'll be consistent and comparable across accounts.
You can also try our free Engagement Calculator to spot-check rates without writing code.
Tracking Competitors and Brand Mentions
Analytics become strategic when you go beyond your own account. Here's where API-driven analytics really earn their value.
Last year, I helped a mid-size e-commerce marketing agency set up competitive monitoring for a client. They needed to track 15 competitor accounts -- weekly tweet volume, engagement rates, and brand mention sentiment. Their previous setup used the old X API Pro tier at $5,000/month. After X switched to pay-per-use, their costs became unpredictable because each resource fetch was individually charged.
We restructured their pipeline around Sorsa API. The workflow:
Competitor timeline tracking. A weekly cron job calls /user-tweets for each competitor, collects the last 20 tweets, and calculates average engagement rate. For 15 accounts, that's 15 requests per week.
Brand mention monitoring. The /mentions endpoint pulls tweets mentioning the client's brand handle. The built-in filters -- min_likes, min_retweets, since_date, until_date -- let them focus on mentions that actually have reach, skipping noise from zero-engagement tweets.
Follower comparison. A monthly snapshot via /info for each competitor tracks follower count changes over time.
Total monthly cost on the Starter plan: around $35-40 for ~7,000 requests. That's a 99% reduction from their previous setup, and the data is actually more granular -- they get bookmark counts and quote counts that weren't available before.
The pattern scales. If you're building a competitor analysis dashboard for a SaaS product or an agency reporting tool, the same endpoints cover the core data layer. The analytics logic -- engagement rate calculations, trend detection, anomaly flagging -- lives in your code on top of clean JSON responses.
What Happened to Academic Research Access?
If you're a researcher hoping for free, expansive access to Twitter data, the news isn't great.
The Academic Research access tier that once provided full-archive search at no cost has been effectively discontinued. X still technically accepts applications under a narrow path: the DSA Article 40 program, which serves EU-affiliated researchers studying systemic risks under the Digital Services Act.
The requirements are strict. Applicants must be affiliated with a recognized non-profit research organization, disclose all funding sources, demonstrate independence from commercial interests, and prove they have adequate data security measures. The application form asks for detailed justification of why X data specifically is needed and cannot be obtained through other means.
From what I've seen across the research community, the vast majority of applications are rejected. If your research only requires public tweet metrics and engagement data -- not private user information or streaming firehose access -- a third-party API is the practical path. You get structured JSON with the same public metrics, without the months-long approval process.
FAQ
Can I get analytics for someone else's tweets?
Yes, but only public metrics. The X API v2 public_metrics field (likes, retweets, replies, quotes, views, bookmarks) is available for any public tweet when using a Bearer Token. The organic_metrics field -- which includes a more detailed breakdown -- is restricted to tweets authored by the authenticated user.
Third-party APIs like Sorsa API return the same public metrics for any public tweet or account.
Is the Twitter Analytics dashboard free?
No. Since 2023, the native X Analytics dashboard is only available to Premium (verified) subscribers on X. Free account holders have no access to the dashboard or any analytics UI on the platform.
How much does the X API charge for reading tweet metrics?
The X API uses pay-per-use pricing. Reading a post costs $0.005 per resource. Reading a user profile costs $0.010 per resource. There are no subscriptions or monthly caps -- you purchase credits upfront and they're deducted with each API call.
What is the difference between views and impressions on Twitter/X?
In the context of public tweet data, "views" and "impressions" refer to the same thing -- the number of times a tweet appeared on someone's screen. The X API v2 labels this field impression_count inside public_metrics. Sorsa API labels it view_count. The number is the same.
In the X Ads API, "impressions" is a different metric that specifically tracks paid ad delivery. Don't confuse the two.
Can I get historical tweet analytics through an API?
Yes. Both the X API v2 (full-archive search) and Sorsa API (/search-tweets) support searching tweets going back to 2006. Every tweet returned includes current engagement metrics. The metrics reflect the present state -- you're seeing how many likes a 2020 tweet has right now, not how many it had in 2020.
How do I track follower growth over time with an API?
No API -- official or third-party -- provides a historical follower count graph. To track growth, you need to periodically request the user's profile (via X API GET /2/users/{id} or Sorsa API /info) and store the followers_count value in your own database. Daily snapshots are enough for most use cases.
Getting Started
If you want to explore what's possible before writing code, start with the free tools that don't require an API key:
- API Playground -- test any endpoint through a web UI. Enter a username and see live tweet data with all metrics.
- Engagement Calculator -- input any public account and get engagement rate calculated from recent tweets.
When you're ready for programmatic access, grab an API key and follow the quickstart guide to make your first request in under five minutes.
For a detailed cost comparison between the official X API and alternatives, see our breakdown in Twitter API Pricing in 2026.
Last verified: April 2026