-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
316 lines (303 loc) · 12.3 KB
/
Copy pathindex.html
File metadata and controls
316 lines (303 loc) · 12.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Official TwexAPI documentation and developer guide for building with X/Twitter-style public data.">
<title>TwexAPI Developer Docs</title>
<link rel="stylesheet" href="styles.css">
<script src="script.js" defer></script>
</head>
<body>
<header class="site-header">
<a class="brand" href="#overview" aria-label="TwexAPI overview">
<span class="brand-mark">T</span>
<span>TwexAPI</span>
</a>
<button class="nav-toggle" type="button" aria-expanded="false" aria-controls="site-nav">
<span class="nav-toggle-line"></span>
<span class="nav-toggle-line"></span>
<span class="nav-toggle-line"></span>
<span class="sr-only">Toggle navigation</span>
</button>
<nav class="site-nav" id="site-nav" aria-label="Primary navigation">
<a href="#overview">Overview</a>
<a href="#quickstart">Quickstart</a>
<a href="#authentication">Authentication</a>
<a href="#endpoints">Endpoints</a>
<a href="#examples">Examples</a>
<a href="#errors">Errors</a>
<a href="#faq">FAQ</a>
<a href="#contact">Contact</a>
</nav>
</header>
<main>
<section class="hero section" id="overview">
<div class="hero-copy">
<p class="eyebrow">Official developer guide</p>
<h1>TwexAPI</h1>
<p class="hero-text">
Access X/Twitter-style public data through predictable API calls for profiles,
timelines, trends, and search workflows.
</p>
<div class="hero-actions" aria-label="Primary actions">
<a class="button primary" href="#quickstart">Start quickstart</a>
<a class="button secondary" href="#endpoints">View endpoints</a>
</div>
<dl class="hero-stats" aria-label="TwexAPI highlights">
<div>
<dt>First request</dt>
<dd>3 min</dd>
</div>
<div>
<dt>Auth model</dt>
<dd>Bearer token</dd>
</div>
<div>
<dt>Format</dt>
<dd>JSON</dd>
</div>
</dl>
</div>
<div class="code-card" aria-label="Example API request">
<div class="code-card-header">
<span>GET /twitter/{username}/about</span>
<button class="copy-button" type="button" data-copy-target="hero-curl">Copy</button>
</div>
<pre class="code-block"><code id="hero-curl">curl "https://api.twexapi.com/twitter/elonmusk/about" \
-H "Authorization: Bearer $TWEXAPI_KEY"</code></pre>
<div class="response-preview">
<span class="status-dot"></span>
<span>200 OK</span>
</div>
<pre class="code-block response"><code>{
"username": "elonmusk",
"name": "Elon Musk",
"verified": true,
"followers_count": 184000000,
"profile_url": "https://x.com/elonmusk"
}</code></pre>
</div>
</section>
<section class="section two-column" id="quickstart">
<div>
<p class="eyebrow">Quickstart</p>
<h2>Three minutes to your first request</h2>
<p>
Set an API key, send a signed request, and receive normalized JSON that is ready
for enrichment, monitoring, dashboards, or internal tools.
</p>
</div>
<div class="steps">
<article class="step">
<span class="step-number">1</span>
<h3>Store your key</h3>
<p>Use an environment variable so credentials stay out of source control.</p>
<div class="code-card compact">
<div class="code-card-header">
<span>.env</span>
<button class="copy-button" type="button" data-copy-target="env-example">Copy</button>
</div>
<pre class="code-block"><code id="env-example">TWEXAPI_KEY=twexapi_demo_key</code></pre>
</div>
</article>
<article class="step">
<span class="step-number">2</span>
<h3>Call an endpoint</h3>
<p>Pass your bearer token in the `Authorization` header.</p>
<div class="code-card compact">
<div class="code-card-header">
<span>Node fetch</span>
<button class="copy-button" type="button" data-copy-target="quickstart-js">Copy</button>
</div>
<pre class="code-block"><code id="quickstart-js">const response = await fetch(
"https://api.twexapi.com/twitter/elonmusk/about",
{
headers: {
Authorization: `Bearer ${process.env.TWEXAPI_KEY}`
}
}
);
const profile = await response.json();
console.log(profile.username);</code></pre>
</div>
</article>
<article class="step">
<span class="step-number">3</span>
<h3>Handle the response</h3>
<p>Check status codes first, then read the JSON payload for normalized fields.</p>
</article>
</div>
</section>
<section class="section split-panel" id="authentication">
<div>
<p class="eyebrow">Authentication</p>
<h2>Bearer tokens in every request</h2>
<p>
TwexAPI requests use a single bearer token. Keep it on the server side,
rotate it when needed, and never ship it in browser client code.
</p>
</div>
<div class="code-card">
<div class="code-card-header">
<span>Authorization header</span>
<button class="copy-button" type="button" data-copy-target="auth-header">Copy</button>
</div>
<pre class="code-block"><code id="auth-header">Authorization: Bearer $TWEXAPI_KEY</code></pre>
<ul class="check-list">
<li>Use HTTPS for every request.</li>
<li>Keep keys in environment variables or secret managers.</li>
<li>Use `twexapi_demo_key` only in examples and tests.</li>
</ul>
</div>
</section>
<section class="section" id="endpoints">
<div class="section-heading">
<p class="eyebrow">Endpoints</p>
<h2>Core API surface</h2>
<p>Start with a small set of high-value endpoints, then expand as your workflow grows.</p>
</div>
<div class="endpoint-grid">
<article class="endpoint-card">
<span class="method">GET</span>
<h3>/twitter/{username}/about</h3>
<p><code>GET /twitter/{username}/about</code></p>
<p>Fetch normalized profile metadata, verification state, follower counts, and profile links.</p>
</article>
<article class="endpoint-card">
<span class="method">GET</span>
<h3>/twitter/{username}/tweets</h3>
<p><code>GET /twitter/{username}/tweets</code></p>
<p>Retrieve recent public timeline posts for monitoring, research, and content workflows.</p>
</article>
<article class="endpoint-card">
<span class="method">GET</span>
<h3>/twitter/trends</h3>
<p><code>GET /twitter/trends</code></p>
<p>Read trending topics for market scans, editorial planning, and discovery tools.</p>
</article>
<article class="endpoint-card">
<span class="method">GET</span>
<h3>/twitter/search/users</h3>
<p><code>GET /twitter/search/users</code></p>
<p>Search public accounts by keyword to build lead lists, creator maps, or research sets.</p>
</article>
</div>
</section>
<section class="section two-column" id="examples">
<div>
<p class="eyebrow">Examples</p>
<h2>Build common workflows quickly</h2>
<p>
The examples are intentionally plain JavaScript so they can move into workers,
backend routes, scripts, or data pipelines without framework lock-in.
</p>
</div>
<div class="code-card">
<div class="code-card-header">
<span>Profile enrichment workflow</span>
<button class="copy-button" type="button" data-copy-target="example-workflow">Copy</button>
</div>
<pre class="code-block"><code id="example-workflow">async function loadCreatorProfile(username) {
const endpoint = `https://api.twexapi.com/twitter/${username}/about`;
const response = await fetch(endpoint, {
headers: {
Authorization: `Bearer ${process.env.TWEXAPI_KEY}`
}
});
if (!response.ok) {
throw new Error(`TwexAPI request failed: ${response.status}`);
}
const profile = await response.json();
return {
handle: profile.username,
name: profile.name,
verified: profile.verified,
followers: profile.followers_count,
url: profile.profile_url
};
}</code></pre>
</div>
</section>
<section class="section" id="errors">
<div class="section-heading">
<p class="eyebrow">Errors</p>
<h2>Predictable status codes</h2>
<p>Check HTTP status first, then inspect the JSON body for a stable error code and message.</p>
</div>
<div class="error-grid">
<article class="error-card" data-status="400">
<strong>400</strong>
<span>Invalid request</span>
<p>Check the parameter name, type, and allowed range before retrying.</p>
</article>
<article class="error-card" data-status="401">
<strong>401</strong>
<span>Unauthorized</span>
<p>Confirm the bearer token exists, is active, and is sent on the server side.</p>
</article>
<article class="error-card" data-status="404">
<strong>404</strong>
<span>Not found</span>
<p>Verify the username, resource path, and whether the public resource exists.</p>
</article>
<article class="error-card" data-status="429">
<strong>429</strong>
<span>Rate limited</span>
<p>Retry after the window resets and add backoff to scheduled jobs.</p>
</article>
<article class="error-card" data-status="500">
<strong>500</strong>
<span>Service error</span>
<p>Retry with backoff and log the request id for support follow-up.</p>
</article>
</div>
<div class="code-card">
<div class="code-card-header">
<span>Error response</span>
<button class="copy-button" type="button" data-copy-target="error-response">Copy</button>
</div>
<pre class="code-block response"><code id="error-response">{
"error": {
"code": "rate_limited",
"message": "Retry after the current window resets.",
"request_id": "req_demo_123"
}
}</code></pre>
</div>
</section>
<section class="section" id="faq">
<div class="section-heading">
<p class="eyebrow">FAQ</p>
<h2>Common implementation questions</h2>
</div>
<div class="faq-list">
<article>
<h3>Can I call TwexAPI from browser code?</h3>
<p>Use a server-side route or worker so your bearer token never ships to end users.</p>
</article>
<article>
<h3>What does the API return?</h3>
<p>Responses are JSON objects with normalized fields designed for application code and data pipelines.</p>
</article>
<article>
<h3>Is there a live playground?</h3>
<p>The first showcase version focuses on readable docs and copyable examples.</p>
</article>
</div>
</section>
<section class="section contact-band" id="contact">
<div>
<p class="eyebrow">Contact</p>
<h2>Ready to build with TwexAPI?</h2>
<p>Request access, ask about endpoint coverage, or share the workflow you want to support.</p>
</div>
<a class="button primary" href="mailto:support@twexapi.com">Request access</a>
</section>
</main>
<footer class="site-footer">
<span>TwexAPI</span>
<span>Official documentation and developer guide.</span>
</footer>
</body>
</html>