Twitter Data
Retrieves detailed analytics for any public tweet, returning view counts, likes, retweets, and engagement metrics.
API Introduction
About This API
The Twitter Data API is a service designed to retrieve detailed, public information about X (formerly Twitter) user profiles and individual tweets. It provides two primary functions: a user-centric query to fetch comprehensive profile data using a username or user ID, and a tweet-centric query to obtain specific details and engagement metrics for any given tweet ID. The API delivers all data in a structured JSON format, making it straightforward for developers to integrate real-time social data into their applications, dashboards, and analytical workflows.
Key Features
- Comprehensive User Profiles: Retrieve in-depth user account information, including follower and following counts, tweet count, account creation date, verification status (blue checkmark), profile pictures, and banner URLs.
- Detailed Tweet Analytics: Get precise engagement metrics for any public tweet, such as the number of views, likes (
favorite_count
), retweets, replies, and quote tweets. - Media Extraction: Extract direct URLs for media (images) and videos attached to tweets, allowing for easy display or archiving of visual content.
- Flexible Lookups: Query user data with either a
username
or auser_id
, providing flexibility in how you identify and retrieve profile information. - Author Information: Each tweet detail request includes a nested user object, providing key information about the tweet's author, such as their username and follower count.
Use Cases
Scenario 1: Building a Brand Campaign Monitor
- Situation: A marketing agency needs to track the real-time performance of a specific promotional tweet sent out by a client.
- Implementation: The agency's internal dashboard takes the
tweet_id
of the promotional tweet. It then periodically calls the/x/v1/tweet_details
endpoint to fetch the latest engagement numbers, specifically monitoring theviews
,favorite_count
, andretweet_count
to measure the campaign's reach and impact.
Scenario 2: Creating an Influencer Vetting Tool
- Situation: A brand wants to quickly assess the authenticity and history of potential influencers before starting a collaboration.
- Implementation: An analyst enters an influencer's X username into the tool. The backend calls the
/x/v1/user_details
endpoint to retrieve key profile metrics likefollower_count
, accountcreation_date
,number_of_tweets
, and verification status. This data provides a quick, data-driven snapshot to help validate the influencer's credibility.
Scenario 3: Powering a Social Media Archiving Service
- Situation: A research organization or news outlet needs to archive significant tweets related to breaking news events for historical records.
- Implementation: When a noteworthy tweet is identified, its
tweet_id
is logged. The service's backend then calls the/x/v1/tweet_details
endpoint to get a complete, structured snapshot of the tweet's content (text
), media (media_url
), and engagement stats at that moment. It also calls/x/v1/user_details
using the author'suser_id
to archive the profile data of the person who posted it.
How it Works: Endpoints & Response
The API operates with two distinct endpoints for retrieving user and tweet data. A valid apikey
is required for all requests.
User Endpoint: GET /x/v1/user_details
By providing a username
or user_id
parameter, this endpoint returns a single JSON object. This object contains a data
key with a comprehensive set of user profile attributes, including their follower stats, profile text, banner URLs, and verification status.
Tweet Endpoint: GET /x/v1/tweet_details
By providing a tweet_id
parameter, this endpoint returns a JSON object containing detailed information about that specific tweet. The data
object includes the tweet's text content, creation date, all engagement counts (views, retweets, etc.), and any associated media URLs.