apitweet-cli 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 jiangyong
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,349 @@
1
+ # apitweet-cli
2
+
3
+ > apitweet-cli is a Node.js command-line client for ApiTweet Twitter/X endpoints. It helps developers and AI agents fetch Twitter/X data, manage API credentials, preview write actions, publish X Articles from Markdown, and automate common X workflows from the terminal.
4
+
5
+ ## Quick facts
6
+
7
+ - Product: `apitweet-cli`
8
+ - Category: Twitter/X API command-line client
9
+ - Runtime: Node.js 18 or newer
10
+ - Best for: developers, AI agents, growth teams, content operators, and automation workflows
11
+ - Main use cases: Twitter/X data retrieval, global trending tweet lookup, tweet/list/profile actions, DM workflows, and Markdown-to-X-Article publishing
12
+ - API provider: ApiTweet
13
+ - Default API base URL: `https://apitweet.com`
14
+ - Authentication: Bearer API key plus optional saved cookie or `auth_token` profile for write actions
15
+ - Interfaces: terminal CLI, raw API path calls, Claude/Codex/OpenClaw skill usage
16
+ - License: MIT
17
+ - Dashboard: [apitweet dashboard](https://apitweet.com/dashboard)
18
+
19
+ ## What it does
20
+
21
+ - Calls ApiTweet Twitter/X endpoints from the terminal with a stable `apitweet` command.
22
+ - Saves reusable app configs for API keys and base URLs.
23
+ - Saves reusable auth profiles for cookies, `auth_token`, and `ct0` values.
24
+ - Supports generic HTTP-style requests to any ApiTweet path.
25
+ - Provides convenience commands for users, search, followers/following, lists, tweets, articles, DMs, profile, timeline, global trending tweets, and follow/unfollow actions.
26
+ - Publishes Markdown files as X Articles through the documented draft, cover, title, content, and publish workflow.
27
+ - Prints dry-run previews for request payloads before sending them.
28
+ - Masks secrets in config output and dry-run previews.
29
+
30
+ ## Who it is for
31
+
32
+ - Developers who want a terminal-first client for Twitter/X data and actions.
33
+ - AI agent builders who need deterministic commands, JSON output, and dry-run previews.
34
+ - Growth and research teams that monitor Twitter/X profiles, search terms, followers, lists, and global trending tweets.
35
+ - Content teams that draft articles in Markdown and publish them as X Articles.
36
+ - Operators who need saved profiles for repeatable Twitter/X workflows without rewriting API request code.
37
+
38
+ ## AI agent use cases
39
+
40
+ apitweet-cli is designed to be easy for AI coding agents and workflow agents to use safely:
41
+
42
+ - Preview a write action with `--dry-run` before publishing, following, liking, or updating anything.
43
+ - Fetch structured Twitter/X data as JSON for downstream summarization or enrichment.
44
+ - Call unsupported endpoints through the raw `apitweet <path>` form.
45
+ - Use saved app and profile names instead of pasting credentials into every command.
46
+ - Publish a Markdown article with a single command while the CLI handles the multi-step X Article API flow.
47
+ - Install and invoke the repository as a Claude/Codex/OpenClaw-style skill.
48
+
49
+ ## Common workflows
50
+
51
+ ### Fetch Twitter/X user data
52
+
53
+ ```bash
54
+ apitweet --app prod about elonmusk
55
+ apitweet --app prod users elonmusk sama
56
+ ```
57
+
58
+ ### Search Twitter/X content
59
+
60
+ ```bash
61
+ apitweet --app prod search tweets "founder" "ai" --count 20
62
+ apitweet --app prod search users "openai"
63
+ ```
64
+
65
+ ### Get global trending tweets
66
+
67
+ ```bash
68
+ apitweet --app prod trending tweets --country "United States" --topic "Sports" --content "NFL" --count 50
69
+ ```
70
+
71
+ ### Publish Markdown as an X Article
72
+
73
+ ```bash
74
+ apitweet --app prod --profile founder --dry-run article publish-md ./article.md --title "Launch Notes"
75
+ apitweet --app prod --profile founder article publish-md ./article.md --title "Launch Notes" --cover-image "https://example.com/cover.jpg" --visibility Public
76
+ ```
77
+
78
+ ### Run a raw ApiTweet request
79
+
80
+ ```bash
81
+ apitweet --app prod -X POST -d '["elonmusk","sama"]' /api/twitter/users
82
+ ```
83
+
84
+ ## Why it is different
85
+
86
+ - It combines convenience commands with raw path access, so users are not blocked when an endpoint is not wrapped yet.
87
+ - It supports both read workflows and authenticated write workflows.
88
+ - It treats AI-agent safety as a first-class workflow through `--dry-run`, secret masking, and saved profile names.
89
+ - It includes skill/plugin metadata so agents can discover how to install, configure, and run the CLI.
90
+ - It keeps the implementation small and dependency-free, with separate modules for parsing, config, request execution, and command routing.
91
+
92
+ ## Install
93
+
94
+ Install globally from npm:
95
+
96
+ ```bash
97
+ npm install -g apitweet-cli
98
+ apitweet --help
99
+ ```
100
+
101
+ Requires Node.js 18 or newer.
102
+
103
+ ## Use as a skill
104
+
105
+ Install from a GitHub skill installer:
106
+
107
+ ```bash
108
+ npx skills add ali/apitweet
109
+ ```
110
+
111
+ Install from ClawHub:
112
+
113
+ ```bash
114
+ npx clawhub@latest install apitweet-cli
115
+ ```
116
+
117
+ Install as a Claude Code marketplace:
118
+
119
+ ```text
120
+ /plugin marketplace add ali/apitweet
121
+ /plugin install apitweet-cli@apitweet-cli
122
+ ```
123
+
124
+ For manual Claude Code installs, this repository also includes:
125
+
126
+ ```text
127
+ .claude/skills/apitweet-cli/
128
+ ```
129
+
130
+ Then install the CLI:
131
+
132
+ ```bash
133
+ npm install -g apitweet-cli
134
+ ```
135
+
136
+ In skills-enabled environments:
137
+
138
+ - use `/apitweet-cli` after installing the Claude plugin command
139
+ - use `$apitweet-cli` in Codex/OpenClaw-style environments
140
+ - or ask the agent to use apitweet for installation, auth setup, dry-run previews, or endpoint calls
141
+
142
+ ## Quick start
143
+
144
+ Get your API key from the apitweet dashboard:
145
+
146
+ [apitweet dashboard](https://apitweet.com/dashboard)
147
+
148
+ Save an app config and make a first request:
149
+
150
+ ```bash
151
+ apitweet auth apps add --name prod --api-key "sk_1d90c878..."
152
+ apitweet auth apps use prod
153
+ apitweet --app prod about elonmusk
154
+ ```
155
+
156
+ If you are developing from this repository, use:
157
+
158
+ ```bash
159
+ cd /home/ali/GitHub/apitweet
160
+ node ./bin/apitweet.js --help
161
+ ```
162
+
163
+ If you want a local executable command while developing from source:
164
+
165
+ ```bash
166
+ npm link
167
+ apitweet --help
168
+ ```
169
+
170
+ ## Config management
171
+
172
+ When a request is missing an API key, the CLI will include that URL in the error output.
173
+
174
+ ## Security notes
175
+
176
+ - The CLI reads `APITWEET_KEY`, `APITWEET_BASE_URL`, and `APITWEET_CONFIG_DIR` from the environment.
177
+ - The CLI reads and writes persistent config in `~/.apitweet/config.json` by default, or in the directory set by `--config-dir` or `APITWEET_CONFIG_DIR`.
178
+ - Saved app configs may contain API keys, and saved profiles may contain cookies, `auth_token`, or `ct0` in plain JSON on disk.
179
+ - Avoid storing long-lived credentials on shared machines or CI runners. Prefer an isolated config directory when testing.
180
+ - `auth cookie` builds a request path containing the `auth_token`, so treat logs, traces, and network boundaries accordingly.
181
+
182
+ Save an app config:
183
+
184
+ ```bash
185
+ apitweet auth apps add --name prod --api-key "sk_1d90c878..."
186
+ apitweet auth apps list
187
+ apitweet auth apps use prod
188
+ ```
189
+
190
+ Save a write profile:
191
+
192
+ ```bash
193
+ apitweet auth profiles add --name founder --cookie "ct0=...; auth_token=..."
194
+ apitweet auth profiles use founder
195
+ ```
196
+
197
+ Create a profile from `auth_token` via the documented cookie endpoint:
198
+
199
+ ```bash
200
+ apitweet auth cookie --auth-token "your_auth_token" --save-as founder
201
+ ```
202
+
203
+ Inspect config:
204
+
205
+ ```bash
206
+ apitweet config show
207
+ apitweet config path
208
+ ```
209
+
210
+ By default config is stored in `~/.apitweet/config.json`. For testing, you can isolate it:
211
+
212
+ ```bash
213
+ apitweet --config-dir ./.apitweet-local config show
214
+ ```
215
+
216
+ ## Request examples
217
+
218
+ Query an endpoint directly:
219
+
220
+ ```bash
221
+ apitweet /api/twitter/elonmusk/about
222
+ ```
223
+
224
+ Send a JSON body with a POST:
225
+
226
+ ```bash
227
+ apitweet -X POST -d '["elonmusk","sama"]' /api/twitter/users
228
+ ```
229
+
230
+ Preview a request without sending it:
231
+
232
+ ```bash
233
+ apitweet --app prod --dry-run users elonmusk sama
234
+ apitweet --app prod --profile founder --dry-run tweet create --text "hello"
235
+ apitweet --app prod --profile founder --dry-run article publish-md ./article.md --title "Launch Notes"
236
+ ```
237
+
238
+ ## Convenience commands
239
+
240
+ Read commands:
241
+
242
+ ```bash
243
+ # Twitter/X User and Search
244
+ apitweet --app prod users elonmusk sama # Lookup user profiles
245
+ apitweet --app prod about elonmusk # Fetch detailed user info
246
+ apitweet --app prod search tweets "founder" "ai" # Search for tweets
247
+ apitweet --app prod search users "openai" # Search for users
248
+ apitweet --app prod followers elonmusk # List user followers
249
+ apitweet --app prod following elonmusk # List user following
250
+
251
+ # Twitter/X Lists
252
+ apitweet --app prod list search --query "ai" # Search for public lists
253
+ apitweet --app prod list members 123456789 # List members of a list
254
+ apitweet --app prod list subscribers 123456789 # List subscribers of a list
255
+
256
+ # Twitter/X Articles & DMs
257
+ apitweet --app prod article markdown 123 # Get x article as Markdown
258
+ apitweet --app prod article lookup 123 456 # Batch lookup x articles
259
+ apitweet --app prod dm history elonmusk # Show Direct Message history
260
+ apitweet --app prod dm send elonmusk --text "hi" # Send a DM to a user
261
+
262
+ # Twitter/X Profile & Timeline
263
+ apitweet --app prod timeline user elonmusk # Fetch user timeline page
264
+ apitweet --app prod profile update --name "Name" # Update your own profile
265
+
266
+ # Twitter/X Global Trending
267
+ apitweet --app prod trending tweets --country "United States"
268
+ apitweet --app prod trending tweets --country "United States" --topic "Sports" --content "NFL" --count 50
269
+
270
+ # Twitter/X Tweets
271
+ apitweet --app prod tweet lookup 123 --summary # Batch tweet lookup (id:bool)
272
+ apitweet --app prod tweet replies 123 # Get replies for a tweet
273
+ ```
274
+
275
+ Write commands:
276
+
277
+ ```bash
278
+ apitweet --app prod --profile founder tweet create --text "hello from cli"
279
+ apitweet --app prod --profile founder tweet create --text "hello with image" --media-url "https://example.com/a.jpg"
280
+ apitweet --app prod --profile founder tweet quote --text "worth reading" --quote-url "https://x.com/user/status/123"
281
+ apitweet --app prod --profile founder tweet like 1900000000000000000
282
+ apitweet --app prod --profile founder tweet unlike 1900000000000000000
283
+ apitweet --app prod --profile founder tweet bookmark 1900000000000000000
284
+ apitweet --app prod --profile founder tweet unbookmark 1900000000000000000
285
+ apitweet --app prod --profile founder tweet retweet 1900000000000000000
286
+ apitweet --app prod --profile founder tweet unretweet 1900000000000000000
287
+ apitweet --app prod --profile founder article publish-md ./article.md --title "Launch Notes"
288
+ apitweet --app prod --profile founder article publish-md ./article.md --title "Launch Notes" --cover-image "https://example.com/cover.jpg" --visibility Public
289
+ apitweet --app prod --profile founder list create --name "AI Builders" --description "Interesting builders" --private
290
+ apitweet --app prod --profile founder user follow someuser
291
+ apitweet --app prod --profile founder user unfollow someuser
292
+ ```
293
+
294
+ ## FAQ
295
+
296
+ ### What is apitweet-cli?
297
+
298
+ apitweet-cli is a Node.js command-line client for ApiTweet Twitter/X endpoints. It lets users call Twitter/X API workflows from the terminal, including user lookup, tweet search, global trending tweets, tweet actions, list actions, DM workflows, profile updates, and X Article publishing.
299
+
300
+ ### Does apitweet-cli require an API key?
301
+
302
+ Yes. Read requests require a ApiTweet API key passed with `--api-key`, `APITWEET_KEY`, or a saved app config created with `apitweet auth apps add`.
303
+
304
+ ### Can apitweet-cli perform write actions on X?
305
+
306
+ Yes. Write actions such as tweeting, liking, following, updating a profile, sending DMs, creating lists, and publishing X Articles require a saved profile or explicit cookie/auth token. Use `--dry-run` first to preview the request.
307
+
308
+ ### Can apitweet-cli publish X Articles from Markdown?
309
+
310
+ Yes. Use `apitweet article publish-md <file.md> --title <title>`. The CLI creates a draft, optionally sets a cover image, sets the article title, uploads Markdown content, and publishes the article.
311
+
312
+ ### Is apitweet-cli suitable for AI agents?
313
+
314
+ Yes. It exposes deterministic commands, JSON responses, dry-run previews, saved credential profiles, and skill/plugin metadata for Claude, Codex, and OpenClaw-style environments.
315
+
316
+ ### Can apitweet-cli call endpoints that do not have convenience commands?
317
+
318
+ Yes. Use the raw path form, for example `apitweet /api/twitter/elonmusk/about` or `apitweet -X POST -d '["elonmusk"]' /api/twitter/users`.
319
+
320
+ ## Limitations
321
+
322
+ - A ApiTweet API key is required for real API requests.
323
+ - Write actions require a cookie, `auth_token`, or saved profile.
324
+ - Saved app configs and profiles are stored as plain JSON on disk.
325
+ - Direct local file upload for tweet media is not included; tweet creation currently supports `--media-url`.
326
+ - The CLI is a terminal client, not a web dashboard or hosted API service.
327
+
328
+ ## Project layout
329
+
330
+ ```text
331
+ bin/apitweet.js # thin executable entrypoint
332
+ src/index.js # main boot flow
333
+ src/parser.js # global option parsing
334
+ src/config.js # config load/save and auth profile helpers
335
+ src/request.js # HTTP execution and dry-run preview
336
+ src/commands.js # command routing and endpoint mapping
337
+ src/help.js # help text
338
+ src/constants.js # defaults and option metadata
339
+ src/utils.js # shared helpers
340
+ ```
341
+
342
+ ## Notes
343
+
344
+ - Global options such as `--app`, `--profile`, `--api-key`, and `--dry-run` should be placed before the command.
345
+ - All API paths are served under `/api/*`. Convenience commands add this prefix automatically; raw path requests may use `/twitter/...` or `/api/twitter/...`.
346
+ - For unsupported endpoints, use the generic `apitweet <path>` form.
347
+ - The CLI masks secrets in config output and dry-run previews.
348
+ - Direct local file upload for media is not included yet; the current CLI supports `--media-url` for tweet creation.
349
+
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { main } from "../src/index.js";
4
+
5
+ main().catch((error) => {
6
+ console.error("Request failed.");
7
+ if (error?.message) {
8
+ console.error(error.message);
9
+ }
10
+ process.exit(1);
11
+ });
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "apitweet-cli",
3
+ "version": "0.1.1",
4
+ "description": "Command-line client for apitweet APIs with saved app auth and profiles",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "homepage": "https://apitweet.io/dashboard",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/ali/apitweet.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://apitweet.io/dashboard"
14
+ },
15
+ "keywords": [
16
+ "apitweet",
17
+ "twitter",
18
+ "x",
19
+ "cli",
20
+ "api"
21
+ ],
22
+ "files": [
23
+ "bin/",
24
+ "src/",
25
+ "README.md"
26
+ ],
27
+ "bin": {
28
+ "apitweet": "bin/apitweet.js"
29
+ },
30
+ "scripts": {
31
+ "check": "node ./bin/apitweet.js --help",
32
+ "test": "node --test"
33
+ },
34
+ "engines": {
35
+ "node": ">=18"
36
+ }
37
+ }