Workflow·Sales & CRM

X API

X/Twitter API integration for posting tweets, threads, reading timelines, search, and analytics.

You say
Install this skill Read the source first Free Written by affaan-m · unverified publisher
Context cost
1.7k tokensestimated from the bundle, loaded when it triggers
Bundle
1 file · 6.7 kBtext throughout, nothing executable
Licence
MITfree to use
Last change
no release on file
Servers it uses
Noneruns standalone

What it does

X/Twitter API integration for posting tweets, threads, reading timelines, search, and analytics. Covers OAuth auth patterns, rate limits, and platform-native content posting. Use when the user wants to interact with X programmatically.

Installed, it changes the agent in these ways.

What this skill changes about the agent is not written down here yet. The listing was collected from its source, and the description is in its own SKILL.md.

Workflow

Runs a procedure end to end.

social mediaanalytics
Filed under

Sales & CRM

The skill itself

This is the whole product. A skill is instructions the model reads, so there is nothing behind the listing you cannot see first — the front matter loads with every session, and the body below it loads when the skill triggers.

SKILL.md6.7 kB · 236 lines
--- name: x-api description: X/Twitter API integration for posting tweets, threads, reading timelines, search, and analytics. Covers OAuth auth patterns, rate limits, and platform-native content posting. Use when the user wants to interact with X programmatically. metadata: origin: ECC ---
8# X API
9
10> **Drift-prone skill.** X API endpoints, access tiers, quotas, and write
11> permissions change frequently. Verify current developer docs and account
12> access before quoting rate limits or implementing a posting/search flow.
13
14Programmatic interaction with X (Twitter) for posting, reading, searching, and analytics.
15
16## When to Activate
17
18- User wants to post tweets or threads programmatically
19- Reading timeline, mentions, or user data from X
20- Searching X for content, trends, or conversations
21- Building X integrations or bots
22- Analytics and engagement tracking
23- User says "post to X", "tweet", "X API", or "Twitter API"
24
25## Authentication
26
27### OAuth 2.0 Bearer Token (App-Only)
28
29Best for: read-heavy operations, search, public data.
30
31```bash
32# Environment setup
33export X_BEARER_TOKEN="your-bearer-token"
34```
35
36```python
37import os
38import requests
39
40bearer = os.environ["X_BEARER_TOKEN"]
41headers = {"Authorization": f"Bearer {bearer}"}
42
43# Search recent tweets
44resp = requests.get(
45 "https://api.x.com/2/tweets/search/recent",
46 headers=headers,
47 params={"query": "claude code", "max_results": 10}
48)
49tweets = resp.json()
50```
51
52### OAuth 1.0a (User Context)
53
54Required for: posting tweets, managing account, DMs, and any write flow.
55
56```bash
57# Environment setup — source before use
58export X_CONSUMER_KEY="your-consumer-key"
59export X_CONSUMER_SECRET="your-consumer-secret"
60export X_ACCESS_TOKEN="your-access-token"
61export X_ACCESS_TOKEN_SECRET="your-access-token-secret"
62```
63
64Legacy aliases such as X_API_KEY, X_API_SECRET, and X_ACCESS_SECRET may exist in older setups. Prefer the X_CONSUMER_* and X_ACCESS_TOKEN_SECRET names when documenting or wiring new flows.
65
66```python
67import os
68from requests_oauthlib import OAuth1Session
69
70oauth = OAuth1Session(
71 os.environ["X_CONSUMER_KEY"],
72 client_secret=os.environ["X_CONSUMER_SECRET"],
73 resource_owner_key=os.environ["X_ACCESS_TOKEN"],
74 resource_owner_secret=os.environ["X_ACCESS_TOKEN_SECRET"],
75)
76```
77
78## Core Operations
79
80### Post a Tweet
81
82```python
83resp = oauth.post(
84 "https://api.x.com/2/tweets",
85 json={"text": "Hello from Claude Code"}
86)
87resp.raise_for_status()
88tweet_id = resp.json()["data"]["id"]
89```
90
91### Post a Thread
92
93```python
94def post_thread(oauth, tweets: list[str]) -> list[str]:
95 ids = []
96 reply_to = None
97 for text in tweets:
98 payload = {"text": text}
99 if reply_to:
100 payload["reply"] = {"in_reply_to_tweet_id": reply_to}
101 resp = oauth.post("https://api.x.com/2/tweets", json=payload)
102 tweet_id = resp.json()["data"]["id"]
103 ids.append(tweet_id)
104 reply_to = tweet_id
105 return ids
106```
107
108### Read User Timeline
109
110```python
111resp = requests.get(
112 f"https://api.x.com/2/users/{user_id}/tweets",
113 headers=headers,
114 params={
115 "max_results": 10,
116 "tweet.fields": "created_at,public_metrics",
117 }
118)
119```
120
121### Search Tweets
122
123```python
124resp = requests.get(
125 "https://api.x.com/2/tweets/search/recent",
126 headers=headers,
127 params={
128 "query": "from:affaanmustafa -is:retweet",
129 "max_results": 10,
130 "tweet.fields": "public_metrics,created_at",
131 }
132)
133```
134
135### Pull Recent Original Posts for Voice Modeling
136
137```python
138resp = requests.get(
139 "https://api.x.com/2/tweets/search/recent",
140 headers=headers,
141 params={
142 "query": "from:affaanmustafa -is:retweet -is:reply",
143 "max_results": 25,
144 "tweet.fields": "created_at,public_metrics",
145 }
146)
147voice_samples = resp.json()
148```
149
150### Get User by Username
151
152```python
153resp = requests.get(
154 "https://api.x.com/2/users/by/username/affaanmustafa",
155 headers=headers,
156 params={"user.fields": "public_metrics,description,created_at"}
157)
158```
159
160### Upload Media and Post
161
162```python
163# Media upload uses v1.1 endpoint
164
165# Step 1: Upload media
166media_resp = oauth.post(
167 "https://upload.twitter.com/1.1/media/upload.json",
168 files={"media": open("image.png", "rb")}
169)
170media_id = media_resp.json()["media_id_string"]
171
172# Step 2: Post with media
173resp = oauth.post(
174 "https://api.x.com/2/tweets",
175 json={"text": "Check this out", "media": {"media_ids": [media_id]}}
176)
177```
178
179## Rate Limits
180
181X API rate limits vary by endpoint, auth method, and account tier, and they change over time. Always:
182- Check the current X developer docs before hardcoding assumptions
183- Read x-rate-limit-remaining and x-rate-limit-reset headers at runtime
184- Back off automatically instead of relying on static tables in code
185
186```python
187import time
188
189remaining = int(resp.headers.get("x-rate-limit-remaining", 0))
190if remaining < 5:
191 reset = int(resp.headers.get("x-rate-limit-reset", 0))
192 wait = max(0, reset - int(time.time()))
193 print(f"Rate limit approaching. Resets in {wait}s")
194```
195
196## Error Handling
197
198```python
199resp = oauth.post("https://api.x.com/2/tweets", json={"text": content})
200if resp.status_code == 201:
201 return resp.json()["data"]["id"]
202elif resp.status_code == 429:
203 reset = int(resp.headers["x-rate-limit-reset"])
204 raise Exception(f"Rate limited. Resets at {reset}")
205elif resp.status_code == 403:
206 raise Exception(f"Forbidden: {resp.json().get('detail', 'check permissions')}")
207else:
208 raise Exception(f"X API error {resp.status_code}: {resp.text}")
209```
210
211## Security
212
213- **Never hardcode tokens.** Use environment variables or .env files.
214- **Never commit .env files.** Add to .gitignore.
215- **Rotate tokens** if exposed. Regenerate at developer.x.com.
216- **Use read-only tokens** when write access is not needed.
217- **Store OAuth secrets securely** — not in source code or logs.
218
219## Integration with Content Engine
220
221Use brand-voice plus content-engine to generate platform-native content, then post via X API:
2221. Pull recent original posts when voice matching matters
2232. Build or reuse a VOICE PROFILE
2243. Generate content with content-engine in X-native format
2254. Validate length and thread structure
2265. Return the draft for approval unless the user explicitly asked to post now
2276. Post via X API only after approval
2287. Track engagement via public_metrics
229
230## Related Skills
231
232- brand-voice — Build a reusable voice profile from real X and site/source material
233- content-engine — Generate platform-native content for X
234- crosspost — Distribute content across X, LinkedIn, and other platforms
235- connections-optimizer — Reorganize the X graph before drafting network-driven outreach
236
In the file
SKILL.md760 words
Files1
LicenceMIT
Why you can read it

Nothing in a skill executes. The client loads the text and the model follows it, so a skill can be audited the way a runbook is — by reading it.

What it costs in context

Skills are not billed by the call. They are paid for in context: every token the instructions occupy is a token your code, your diff and your conversation cannot use. Here is what this one takes and when it takes it.

≈70
always loaded
The name and description, so the model knows the skill exists and when to reach for it.
1,605
on trigger
The instruction body, read only when the skill fires.
0.84%
of a 200k window
Ten skills this size would take about 8% of the window before you open a file.
050k100k150k200k context window

1.7k tokens, estimated from the bundle at four bytes to the token, held for the rest of the session once it triggers. Middling. Fine to keep on in a project where you use it weekly, worth unloading in one where you never do.

Servers bill, skills cost

A server charges by the month. A skill charges once per session, in context, and then keeps charging it for as long as the session lives.

Before and after

The same question, put to the same model twice: once as it comes, and once with these instructions loaded.

No worked example has been published for this skill yet.

Adoption
Installsnone yet
Ratingno reviews yet

The procedure it runs

The procedure has not been published here. It is in the skill’s own SKILL.md, which its author has not sent to the marketplace yet.

Prose, not code

These steps are written for a model to follow, not executed by a runtime. It can still be told to skip one, and it will say so when it does.

Servers it uses

None. This skill calls no MCP servers at all.

Everything it needs is in the instructions, so it works in a project with nothing connected — the model reads the file and changes how it works with what it can already reach.

It writes no files and reaches no network. All it changes is how the model reasons and writes.

What it asks for
Writes filesno
Network accessno

Read from the allowed-tools line of this skill’s own SKILL.md. A skill grants no permissions of its own — it can only ask for tools your client already has.

What it will not do

Every skill is narrow, and the useful ones say where they stop. These are the jobs this one is the wrong tool for.

What this skill is not for has not been published here. Nothing is implied by that: it is a section the author has not filled in.

What is in the bundle

1 file, 6.7 kB on disk. A bundle is text throughout: the instructions the model reads, plus the templates it fills in.

  • SKILL.md6.7 kB
What is not in it

No dependencies and nothing executable: a skill is text the agent reads, so the bundle is 1 file you can review in full before installing. The MIT licence covers the templates and examples as well as the instructions.

Install

Installing copies the bundle into your project. Nothing runs at install time — the files sit on disk until the model reads them.

# X API · 1.7k tokens when loaded npx mcprush@latest skill add affaan-m/x-api

Writes to .claude/skills/x-api/ in the current project. Add --global to put it in your home directory instead, for every project.

Which clients pick it up on their own

A skill is a folder of text. A client with a skills folder reads it without being told; everywhere else the same text works, it is just handed to the model rather than found.

Claude Code.claude/skills/
Claude Desktop
ChatGPT
Cursor.cursor/skills/
VS Code.github/skills/
Codex CLI.agents/skills/
Gemini CLI.gemini/skills/
Grok.grok/skills/
Zed.agents/skills/
Windsurf.windsurf/skills/
Agent SDK.claude/skills/
HTTP / API
This release
Versionnot versioned
Publishedno release date on file
PriceFree
Referenceaffaan-m/x-api

Versions

Its author publishes no version number, so there is nothing here to pin to: what you install is the folder as it stands today. Instructions change more often than APIs do — a skill can be rewritten entirely without anything it depends on moving.

v
  • No earlier releases have been published to the marketplace.
Pinning

Nothing to pin to: this skill carries no version number of its own. What you install is what the folder holds on the day you install it.

Reviews

no reviews yet · no installs yet

Nobody has reviewed this skill yet. The rating is the mean of the reviews written here, so there is none until somebody writes the first.

Who can post

Only accounts that have had the skill installed for fourteen days, so a review is written after living with it rather than after reading it. Publishers may reply once.

Publisher
Servers0