Overview

The X API, formerly known as the Twitter API, provides programmatic interfaces for interacting with the X platform. It allows developers to access and publish posts, retrieve user profiles, manage direct messages, and analyze engagement data. The API is designed for a range of applications, including real-time news aggregation, customer service tools, social media marketing platforms, and data analysis systems. Developers can utilize the API to monitor public conversations, disseminate information, and integrate X functionality into their own products or services. Its utility extends across various sectors, from media and entertainment to government and academic research, where access to public discourse and real-time data is critical for decision-making and content creation.

The platform is particularly suited for scenarios requiring immediate access to trending topics and public sentiment. For instance, businesses can track brand mentions and customer feedback, while news organizations can monitor breaking events as they unfold on the platform. The API supports a variety of endpoints to retrieve posts based on keywords, user IDs, or geographic locations, and to manage interactions such as replies, likes, and reposts. Recent updates to the API structure have introduced tiered access, impacting how developers manage existing integrations and build new ones. Developers must review the X API reference documentation to understand the current capabilities and access policies, which have evolved to emphasize structured data access and stricter usage limits for different subscription levels.

While the X API provides extensive data access, developers should also consider alternative platforms depending on specific functional requirements or budgetary constraints. For example, platforms like Reddit's API offerings for community content provide different data models centered around subreddits and upvoting mechanisms, which may be more suitable for forum-style content analysis and interaction. Understanding these differences is crucial for selecting the appropriate social data source for an application.

Key features

  • Post Management: Create, retrieve, update, and delete posts (formerly tweets) programmatically. This includes posting text, images, and videos, as well as managing replies and quoting other posts.
  • User Management: Access user profiles, including follower counts, descriptions, and public posts. Functionality also extends to managing following relationships and direct messages.
  • Search and Filtering: Perform real-time and historical searches for posts based on keywords, hashtags, users, and other parameters. Filters allow for precise data retrieval based on specific criteria.
  • Engagement Metrics: Retrieve data on post engagement, such as likes, reposts, and replies. This allows for analytical applications to track content performance and audience interaction.
  • Streaming API: Access a stream of public posts in real time, enabling applications that require immediate data processing for event monitoring or trend analysis.
  • Direct Messages: Send and receive direct messages, facilitating customer support bots or private communication features within applications.
  • Media Upload: Upload images, GIFs, and videos to be attached to posts, enabling rich content creation through the API.

Pricing

The X API offers several subscription tiers, with varying levels of access and request limits. As of May 2026, a free tier provides basic access, while more extensive access requires paid subscriptions.

Tier Name Monthly Cost Key Features
Free $0 Read 1,500 posts/month, Write 50 posts/month, Upload 10 MB/month media.
Basic $100 Read 10,000 posts/month, Write 3,000 posts/month, Upload 50 MB/month media, Access to v2 API endpoints.
Pro $5,000 Read 1,000,000 posts/month, Write 50,000 posts/month, Upload 1 GB/month media, Increased rate limits, Enhanced search capabilities.
Enterprise Custom Volume-based pricing, Premium access to all v2 API endpoints, Dedicated support, Custom rate limits for high-volume use cases.

For detailed and up-to-date pricing information and specific feature sets for each tier, developers should consult the X API subscriptions page directly.

Common integrations

  • Customer Service Platforms: Integrate X data into customer relationship management (CRM) systems to monitor mentions, respond to inquiries, and manage customer feedback.
  • Social Listening Tools: Develop applications that track brand sentiment, monitor competitors, and identify trending topics by filtering real-time post streams.
  • Content Management Systems (CMS): Automatically publish content to X from a CMS, or embed X posts within web pages and applications.
  • Marketing Automation Platforms: Schedule posts, analyze campaign performance, and manage advertising efforts on X as part of broader marketing strategies.
  • Data Analytics Dashboards: Incorporate X engagement data, follower metrics, and post reach into business intelligence tools for comprehensive reporting.
  • News Aggregators: Build applications that collect and display real-time news and public discourse by filtering posts based on relevant keywords and sources.
  • AI-powered Bots: Create automated assistants that can interact with users, answer questions, or perform tasks on the X platform through direct messages or replies.

Alternatives

  • Meta Platforms (Facebook): Offers APIs for Facebook, Instagram, and WhatsApp, primarily focused on social networking, advertising, and business messaging.
  • Reddit: Provides an API for accessing community-driven content, user interactions, and subreddit data, suitable for forum-based analysis.
  • Mastodon: A decentralized social network with an open API, allowing for custom client development and integration with federated instances.
  • Web Share API: A browser-native API for sharing content from web applications to any installed sharing service, including social media platforms, without direct platform API integration.

Getting started

To get started with the X API, you typically need to authenticate your application and make requests to specific endpoints. The following Python example demonstrates how to retrieve recent posts from your own user account using the tweepy library, a popular Python client for the X API. This example assumes you have already obtained your API keys and access tokens from the X Developer Portal.

import tweepy

# Replace with your actual API keys and tokens
consumer_key = "YOUR_CONSUMER_KEY"
consumer_secret = "YOUR_CONSUMER_SECRET"
access_token = "YOUR_ACCESS_TOKEN"
access_token_secret = "YOUR_ACCESS_TOKEN_SECRET"

# Authenticate with the X API
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

# Create an API object
api = tweepy.API(auth)

try:
    # Get your own user object to find your user ID
    me = api.verify_credentials()
    user_id = me.id

    print(f"Retrieving the 5 most recent posts for user ID: {user_id}")

    # Fetch the 5 most recent posts from your own timeline
    public_posts = api.user_timeline(user_id=user_id, count=5)

    for post in public_posts:
        print(f"Post ID: {post.id}")
        print(f"Text: {post.text}")
        print(f"Created At: {post.created_at}")
        print("---\n")

except tweepy.TweepyException as e:
    print(f"Error: {e}")

This code snippet initializes the API client with your credentials and then retrieves the five most recent public posts from the authenticated user's timeline. Developers can adapt this pattern to interact with other API endpoints, such as searching for posts, posting new content, or managing followers, by referring to the comprehensive X API documentation for specific methods and parameters.