x-api

Post tweets, threads, and media to X and read timelines, search results, and analytics via the X API.

Updated Mar 26, 2026
One-click install
npx skills add https://github.com/inuishan/PET --skill x-api-inuishan
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: x-api
Source: https://github.com/inuishan/PET/tree/main/.codex/skills/x-api
Command: npx skills add https://github.com/inuishan/PET --skill x-api-inuishan

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires requests, requests_oauthlib.

What problem does it solve? Integrating with X (Twitter) programmatically requires navigating two different OAuth schemes, split v1.1/v2 endpoints, and strict rate limits. This Skill provides ready-to-use authentication patterns and code for posting, reading, searching, and analyzing X content without re-deriving the API contract each time. ## Core Features & Use Cases - Posting & Threads: Publish single tweets, multi-tweet threads, and media-attached posts using OAuth 1.0a user-context authentication. - Reading & Search: Fetch user timelines, look up users by username, and run recent-search queries with tweet fields and public metrics using OAuth 2.0 bearer tokens. - Rate Limit & Error Handling: Built-in guidance for rate limit headers, 429 backoff, and 403 permission errors. - Use Case: Generate a product-launch announcement with the content-engine skill, split it into a thread, post it via the X API, and track engagement through public_metrics. ## Quick Start Use the x-api skill to post a tweet announcing our new release and then search X for mentions of it.

Frequently Asked Questions about x-api

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I post a tweet with the X API in Python?▼

Post a tweet by sending a POST request to https://api.x.com/2/tweets with a JSON body containing the text field, authenticated via an OAuth 1.0a user-context session. A successful call returns status 201 with the new tweet ID in the data object.

How to post a Twitter thread programmatically?▼

Post each tweet sequentially, passing the previous tweet's ID in the reply.in_reply_to_tweet_id field of the next request. Collect the returned IDs in order so the thread structure is preserved and each tweet chains to the prior one.

What is the difference between OAuth 2.0 and OAuth 1.0a on the X API?▼

OAuth 2.0 app-only bearer tokens suit read-heavy operations like search and public data retrieval. OAuth 1.0a user-context authentication with API key, secret, access token, and access secret is required for posting tweets, managing the account, and DMs.

Does the X API support uploading images with tweets?▼

Yes, but media upload uses the v1.1 endpoint at upload.twitter.com/1.1/media/upload.json. Upload the file first to get a media_id_string, then reference it in the media.media_ids array when creating the tweet via the v2 endpoint.

Why am I getting a 429 error from the X API?▼

A 429 response means you exceeded the endpoint's rate limit, such as 200 tweet posts per 15 minutes. Check the x-rate-limit-remaining and x-rate-limit-reset headers and wait until the reset timestamp before retrying.