canonical: https://jentic.com/apis/twitter.com/twitter-current

# Twitter API v2

Access and interact with posts, users, direct messages, communities, lists, and Spaces on the Twitter platform through 109 endpoints. Supports full-text search across historical and recent tweets, real-time filtered streams, and compliance data feeds. Provides community management, user relationship lookups, and engagement actions including likes and bookmarks.

## For AI agents

Post tweets, search conversations, stream real-time content, and manage user interactions on Twitter. Supports 109 endpoints covering tweets, DMs, lists, communities, and Spaces.

## Scope

Does not handle ad campaigns, analytics dashboards, or audience insights - use for tweet content, user data, and messaging only.

## Capabilities

- Search historical and recent tweets by keyword, hashtag, or user mention with boolean operators
- Stream real-time tweets matching filter rules via persistent HTTP connections
- Send and retrieve direct messages across conversations with specific participants
- Look up user profiles, followers, and following relationships by ID or username
- Create, delete, and quote tweets with media attachments and polls
- Browse and search Twitter Communities and their member posts
- Retrieve trending topics by geographic location (WOEID)

## Use cases

### AI Agent Social Monitoring

An AI agent searches for tweets mentioning a brand or topic using the /2/tweets/search/recent endpoint, analyzes sentiment and volume, and triggers alerts when engagement spikes. Through Jentic, the agent discovers the search endpoint by intent, loads the query schema, and executes searches without manual API setup. Handles up to 450 requests per 15-minute window on the standard tier.

Example prompt: Search for tweets mentioning '@acme' posted in the last 24 hours using /2/tweets/search/recent and return the 10 most engaged results sorted by retweet count

### Real-Time Content Streaming

Filter and receive tweets in real time matching specific rules - keywords, user handles, geographic locations, or conversation threads. The /2/tweets/search/stream endpoint delivers a persistent HTTP stream of matching tweets within seconds of posting. Supports up to 25 concurrent rules on the basic access level and 1,000 rules on academic research access.

Example prompt: Add a filter rule for tweets containing 'artificial intelligence' with language:en to /2/tweets/search/stream/rules and open the stream connection

### Community Engagement Analysis

Retrieve posts, members, and metadata from Twitter Communities using /2/communities/{id} and /2/communities/search. Analyze engagement patterns within niche communities to identify influential voices and trending discussion topics. Supports pagination through community member lists and post timelines.

Example prompt: Search for Twitter Communities matching 'machine learning' via /2/communities/search and retrieve the top community's member count and recent posts

### Automated Direct Messaging

Send direct messages to users, retrieve conversation histories, and monitor DM events through the /2/dm_conversations endpoints. Supports creating new conversations, sending messages to existing threads, and listing DM events with pagination. Enables customer support bots and notification workflows that communicate privately with users.

Example prompt: Send a direct message 'Your order has shipped!' to participant_id 12345 via POST /2/dm_conversations/with/{participant_id}/messages

### Tweet Publishing and Thread Creation

Publish tweets, create multi-tweet threads, and attach media including images, videos, and polls via POST /2/tweets. Supports reply threading by setting in_reply_to_tweet_id, quote tweets, and scheduled content workflows. Media uploads use the /2/media/upload endpoint with chunked transfer for large files.

Example prompt: Create a tweet thread by posting an initial tweet via POST /2/tweets and replying to it with a second tweet using in_reply_to_tweet_id

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| POST | /2/tweets | Create a new tweet |
| GET | /2/tweets/search/recent | Search recent tweets (last 7 days) |
| GET | /2/tweets/search/all | Full-archive tweet search |
| GET | /2/tweets/search/stream | Real-time filtered tweet stream |
| GET | /2/users/{id} | Look up a user by ID |
| POST | /2/dm_conversations/with/{participant_id}/messages | Send a direct message |
| GET | /2/communities/search | Search Twitter Communities |
| GET | /2/trends/by/woeid/{woeid} | Get trending topics by location |

## Key resources

- **Tweets** — Post, search, stream, count, and retrieve tweets with full metadata
- **Users** — Look up profiles, followers, following, blocks, and mutes
- **Direct Messages** — Send messages, list conversations, and retrieve DM events
- **Communities** — Search and retrieve community details and member posts
- **Lists** — Create, manage, and retrieve tweets from curated user lists
- **Spaces** — Look up live audio Spaces and retrieve participant information

## Why Jentic

- **Setup:** Wiring the Twitter API v2 by hand means choosing between an app-only bearer token and OAuth 2.0 user context, requesting the right read and write scopes, and handling recent-search and stream rate limits yourself. Through Jentic you install once, import the Twitter API v2 from the API Directory, store the token once, and your agent calls it.
- **Permission scoping:** The Twitter API v2 carries new tweets and direct messages in the request body, so scope your agent to the operations it needs, such as searching recent tweets or reading a user. You choose the operations it may call, so a write like posting a tweet or sending a direct message is not included unless you add it.
- **Credential handling:** Your Twitter bearer token and OAuth 2.0 credentials are stored once, encrypted, by your own Jentic One instance and injected at execution time. They never enter the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'search recent tweets about a brand' or 'look up a user', and Jentic returns the matching Twitter API v2 operation with its input schema so the agent calls the right endpoint without browsing the reference docs.

## Related APIs

- **Reddit API** — Community discussion platform with subreddit-based content instead of follower-based timelines
- **Slack API** — Team messaging platform for forwarding tweet alerts or social monitoring results to internal channels
- **Buffer API** — Social media scheduling tool that queues content for posting to Twitter and other platforms

## FAQ

### What authentication does the Twitter API v2 use?

The Twitter API v2 supports three authentication methods: OAuth 2.0 with PKCE for user-context requests (posting tweets, managing DMs), App-only Bearer Token for read-only endpoints (search, user lookup), and OAuth 1.0a User Token for legacy compatibility. Through Jentic, these credentials are stored encrypted in your Jentic One instance and agents receive scoped tokens without handling raw keys directly.

### What are the rate limits for the Twitter API v2 search endpoint?

The /2/tweets/search/recent endpoint allows 450 requests per 15-minute window on Basic access and 300 per 15-minute window on Pro access. Each request returns up to 100 tweets. The /2/tweets/search/all (full-archive) endpoint is available on Academic Research or Pro access at 300 requests per 15-minute window.

### Can I stream tweets in real time with the Twitter API v2?

Yes. The /2/tweets/search/stream endpoint provides a persistent HTTP connection delivering tweets matching your filter rules within seconds of posting. You configure rules via POST /2/tweets/search/stream/rules. Basic access supports 25 concurrent rules; Pro access supports up to 1,000 rules.

### How do I search tweets and post content through Jentic?

Install the Jentic SDK with pip install jentic, then search for 'search recent tweets' to discover the /2/tweets/search/recent operation. Jentic returns the full input schema so your agent can construct the query parameter. For posting, search 'create a tweet' to load the POST /2/tweets schema. Run it through Jentic One, the self-hosted execution layer.

### Can I access historical tweets beyond the 7-day window?

Yes. The /2/tweets/search/all endpoint provides full-archive search going back to the first tweet ever posted. This requires Academic Research or Pro access level. The endpoint supports the same query syntax as recent search with additional operators for time-range filtering using start_time and end_time parameters.

### Does the Twitter API v2 support sending direct messages?

Yes. Use POST /2/dm_conversations/with/{participant_id}/messages to send a DM to a specific user, or POST /2/dm_conversations to create a new group conversation. Retrieve conversation history with GET /2/dm_conversations/with/{participant_id}/dm_events. DM endpoints require OAuth 2.0 user context with the dm.read and dm.write scopes.

### What is the difference between Twitter API v1.1 and v2?

API v2 uses a redesigned data model with expansion fields, supports more granular OAuth 2.0 scopes with PKCE, and adds endpoints for Spaces, Communities, and Bookmarks that do not exist in v1.1. The v2 search endpoint supports a richer query language with conversation_id, context annotations, and entity operators not available in v1.1.

### Can I limit what my agent is allowed to do with the Twitter API v2?

Yes. Jentic One is self-hosted, so your own rules decide which Twitter API v2 operations and credentials the agent may use. You can scope it to read-only work like searching recent tweets or looking up a user, and a write such as posting a tweet or sending a direct message is not included unless you explicitly add it. Because your Twitter token and OAuth 2.0 credentials are injected at execution time rather than handed to the agent, the agent can only call the operations you have granted.
