twexapi-cli
v0.1.0
Published
CLI for twexapi with saved app auth, profiles, and xurl-style requests
Readme
twexapi-cli
An xurl-style CLI for the twexapi service.
What it supports
- Generic HTTP-style requests to twexapi paths
- Saved app configs for API keys and base URLs
- Saved profiles for cookies or
auth_tokenvalues - Convenience commands for users, about, search, followers/following, lists, tweets, and follow/unfollow
- Modular code layout under
src/so config, parsing, requests, and commands evolve independently
Install
If the package has been published to npm, other users can install it globally with:
npm install -g twexapi-cli
twexapi --helpIf you are working from this repository before publishing, use:
cd /Users/jiangyong/code/twexapi-cli
node ./bin/twexapi.js --helpIf you want a local executable command while developing from source:
npm link
twexapi --helpConfig management
Get your API key from the twexapi dashboard:
When a request is missing an API key, the CLI will include that URL in the error output.
Save an app config:
twexapi auth apps add --name prod --api-key "twitterx_..."
twexapi auth apps list
twexapi auth apps use prodSave a write profile:
twexapi auth profiles add --name founder --cookie "ct0=...; auth_token=..."
twexapi auth profiles use founderCreate a profile from auth_token via the documented cookie endpoint:
twexapi auth cookie --auth-token "your_auth_token" --save-as founderInspect config:
twexapi config show
twexapi config pathBy default config is stored in ~/.twexapi/config.json. For testing, you can isolate it:
twexapi --config-dir ./.twexapi-local config showRequest examples
Query an endpoint directly:
twexapi /twitter/elonmusk/aboutSend a JSON body with a POST:
twexapi -X POST -d '["elonmusk","sama"]' /twitter/usersPreview a request without sending it:
twexapi --app prod --dry-run users elonmusk sama
twexapi --app prod --profile founder --dry-run tweet create --text "hello"Convenience commands
Read commands:
twexapi --app prod users elonmusk sama
twexapi --app prod about elonmusk
twexapi --app prod search tweets "founder" "ai" --count 20 --sort Latest
twexapi --app prod search users "openai" --count 20
twexapi --app prod followers elonmusk --count 100
twexapi --app prod following elonmusk --count 100
twexapi --app prod list search --query "ai founders" --count 20
twexapi --app prod list members 123456789 --count 100
twexapi --app prod list subscribers 123456789 --count 100
twexapi --app prod tweet lookup 1900000000000000000 1900000000000000001
twexapi --app prod tweet replies 1900000000000000000 --count 25 --sort RecencyWrite commands:
twexapi --app prod --profile founder tweet create --text "hello from cli"
twexapi --app prod --profile founder tweet create --text "hello with image" --media-url "https://example.com/a.jpg"
twexapi --app prod --profile founder tweet quote --text "worth reading" --quote-url "https://x.com/user/status/123"
twexapi --app prod --profile founder tweet like 1900000000000000000
twexapi --app prod --profile founder tweet unlike 1900000000000000000
twexapi --app prod --profile founder tweet bookmark 1900000000000000000
twexapi --app prod --profile founder tweet unbookmark 1900000000000000000
twexapi --app prod --profile founder tweet retweet 1900000000000000000
twexapi --app prod --profile founder tweet unretweet 1900000000000000000
twexapi --app prod --profile founder list create --name "AI Builders" --description "Interesting builders" --private
twexapi --app prod --profile founder user follow someuser
twexapi --app prod --profile founder user unfollow someuserProject layout
bin/twexapi.js # thin executable entrypoint
src/index.js # main boot flow
src/parser.js # global option parsing
src/config.js # config load/save and auth profile helpers
src/request.js # HTTP execution and dry-run preview
src/commands.js # command routing and endpoint mapping
src/help.js # help text
src/constants.js # defaults and option metadata
src/utils.js # shared helpersNotes
- Global options such as
--app,--profile,--api-key, and--dry-runshould be placed before the command. - For unsupported endpoints, use the generic
twexapi <path>form. - The CLI masks secrets in config output and dry-run previews.
- Direct local file upload for media is not included yet; the current CLI supports
--media-urlfor tweet creation. - DM commands are not included yet because I have not found a confirmed public DM endpoint in the twexapi docs we based this CLI on.
