Overview

The Twitter API, provided by X Corp., offers programmatic interfaces for interacting with the Twitter platform. Developers utilize the API to access public tweet data, publish content, manage user interactions, and integrate social functionalities into external applications. The API is structured to support a range of use cases, from analyzing real-time social conversations to automating content delivery and building customer service tools.

Since its inception, the Twitter API has evolved, with the current version, Twitter API v2, providing more granular control over data access and a more consistent API design than previous iterations. This version emphasizes features such as advanced filtering for public content streams, comprehensive tweet and user object expansion, and improved management of direct messages and media uploads. Developers can filter tweets by keywords, users, locations, and other parameters, enabling focused data collection for sentiment analysis, trend monitoring, or research purposes.

The primary audience for the Twitter API includes data scientists, researchers, marketing professionals, and application developers. It is particularly well-suited for building social monitoring dashboards, automating social media marketing campaigns, and creating applications that require interaction with public social data. For example, a marketing agency might use the API to track brand mentions, while a news organization could use it to monitor breaking stories as they unfold on the platform. Enterprise users often leverage the API for large-scale data ingestion and analysis, integrating tweet data into broader business intelligence systems to gain insights into public perception and market trends.

Recent changes to the Twitter API's access model and pricing have shifted its accessibility. While a free tier remains available for low-volume usage, higher-volume data access and advanced features typically require a paid subscription. This change has influenced how developers approach projects that rely on Twitter data, with a greater emphasis on optimizing API calls and managing subscription costs. Despite these changes, the API remains a resource for accessing a significant volume of public social data, as evidenced by its continued use in academic research and commercial applications.

Key features

  • Tweet publishing and management: Programmatically create, delete, and manage tweets, including those with media attachments and polls.
  • Real-time and historical data access: Stream public tweets in real time or retrieve historical tweet data based on various criteria such as keywords, users, and timeframes.
  • User and account management: Access user profiles, follower lists, and manage relationships (follow/unfollow).
  • Direct message functionality: Send and receive direct messages programmatically, enabling automated customer support or conversational applications.
  • Advanced filtering and search: Utilize robust query language to filter tweet streams and search results by specific parameters, including exact phrases, user mentions, hashtags, and geographic locations.
  • Media upload support: Upload images, videos, and GIFs to be attached to tweets, direct messages, or user profiles.
  • Spaces API: Interact with Twitter Spaces, allowing developers to retrieve metadata about live and scheduled audio conversations.
  • Developer Portal: Access comprehensive documentation, API references, and tools for application management and testing through the Twitter Developer Docs.

Pricing

The Twitter API offers a free tier and several paid tiers designed for different levels of usage and functionality. As of May 2026, the pricing structure includes a free option with limited access, a Basic tier for small-scale projects, and Pro and Enterprise tiers for higher-volume and specialized requirements.

Tier Monthly Cost Included Tweets (per month) Uploads (per month) Key Features
Free $0 500,000 1,500 Write and read Tweets, Limited API access
Basic $100 50,000 2,500 Free tier features + Increased write/read volume, Access to all v2 endpoints
Pro $5,000 1,000,000 50,000 Basic tier features + Higher volume, Enhanced filtering, Enterprise support
Enterprise Custom Custom Custom All Pro features + Highest volume, Dedicated support, Custom solutions

For more detailed and up-to-date pricing information, developers should consult the official Twitter API pricing page.

Common integrations

  • Marketing automation platforms: Integrate for scheduled tweet publishing, campaign monitoring, and audience engagement analysis.
  • Customer service solutions: Enable agents to respond to direct messages and public mentions directly from unified dashboards.
  • Data analytics and business intelligence tools: Ingest tweet data for sentiment analysis, trend tracking, and competitive intelligence.
  • News and media monitoring systems: Monitor real-time discussions around specific topics, events, or public figures.
  • Social media management platforms: Provide comprehensive tools for managing multiple Twitter accounts, scheduling content, and reporting on performance.
  • Research applications: Facilitate data collection for academic and market research, particularly in social science and public opinion studies.

Alternatives

  • Meta Graph API (Facebook): Provides programmatic access to Facebook's platform, including user data, posts, and page management.
  • LinkedIn API: Offers tools for integrating with LinkedIn profiles, company pages, and professional networks.
  • Reddit API: Allows developers to interact with Reddit communities, retrieve posts, comments, and user data.

Getting started

To get started with the Twitter API, you typically need to create a developer account, set up a new project, and generate API keys and tokens. The following Python example demonstrates how to make a simple request to retrieve a user's tweets using the tweepy library, a popular Python wrapper for the Twitter API. This example assumes you have already obtained your bearer token from the Twitter Developer Portal.

import tweepy
import os

# Replace with your actual Bearer Token from the Twitter Developer Portal
bearer_token = os.environ.get("TWITTER_BEARER_TOKEN")

if not bearer_token:
    print("Error: TWITTER_BEARER_TOKEN environment variable not set.")
    print("Please obtain your Bearer Token from the Twitter Developer Portal and set it.")
else:
    client = tweepy.Client(bearer_token)

    # Replace with the desired Twitter username
    username = "apispine"

    # Get User ID from username
    response = client.get_user(username=username)
    if response.data:
        user_id = response.data.id
        print(f"User '{username}' ID: {user_id}")

        # Get user's tweets
        tweets_response = client.get_users_tweets(user_id, tweet_fields=["created_at", "text"], max_results=5)

        if tweets_response.data:
            print(f"\nLatest tweets from @{username}:")
            for tweet in tweets_response.data:
                print(f"- [{tweet.created_at}] {tweet.text}")
        else:
            print(f"No tweets found for @{username}.")
    else:
        print(f"User '{username}' not found or an error occurred.")

Before running this code, ensure you have installed tweepy (pip install tweepy) and set your TWITTER_BEARER_TOKEN as an environment variable. Obtain your Bearer Token by creating an app in the Twitter Developer Portal. This token authenticates your application to access public data according to your assigned access level. For comprehensive guidance on obtaining credentials and making various API calls, refer to the Twitter API Reference.