x-api

Post tweets, threads, and read timelines via the X API.

Updated May 7, 2026
One-click install
npx skills add https://github.com/mirzadham/trainingroombookingsystem2 --skill x-api-mirzadham
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: x-api
Source: https://github.com/mirzadham/trainingroombookingsystem2/tree/main/.agent/.agents/skills/x-api
Command: npx skills add https://github.com/mirzadham/trainingroombookingsystem2 --skill x-api-mirzadham

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires requests, requests-oauthlib.

What problem does it solve? Integrating with X (Twitter) programmatically requires navigating OAuth 1.0a and OAuth 2.0 authentication, versioned endpoints, media upload flows, and shifting rate limits. This Skill provides working code patterns 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, search recent tweets with query operators, and look up users by username with metrics fields. - Rate Limit & Error Handling: Read x-rate-limit headers at runtime, back off automatically, and handle 403/429 responses with structured errors. - Use Case: A content workflow pulls your recent original posts to model your voice, drafts a thread, waits for your approval, then posts it via the X API and tracks engagement through public_metrics. ## Quick Start Use the x-api skill to post a tweet saying "Hello from my automation" using my stored X credentials.

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 OAuth 1.0a user context. Use requests_oauthlib's OAuth1Session with your consumer key, consumer secret, access token, and access token secret.

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 each subsequent POST to /2/tweets. Collect the returned tweet IDs to track the full thread.

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

OAuth 2.0 bearer tokens provide app-only authentication suited for read operations like search and timelines. OAuth 1.0a user-context authentication is required for write actions such as posting tweets, managing the account, and sending direct messages.

How do I upload images and attach them to a tweet?▼

Upload media first via the v1.1 endpoint https://upload.twitter.com/1.1/media/upload.json using OAuth 1.0a, which returns a media_id_string. Then include that ID in the media.media_ids array when posting the tweet to the v2 endpoint.

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

A 429 response means you exceeded the endpoint's rate limit for your auth method and account tier. Read the x-rate-limit-reset header to determine when the limit resets and back off until that timestamp instead of retrying immediately.

Where should I store X API credentials securely?▼

Store credentials as environment variables such as X_BEARER_TOKEN, X_CONSUMER_KEY, and X_ACCESS_TOKEN_SECRET, never in source code. Add .env files to .gitignore and rotate tokens at developer.x.com if they are ever exposed.