twitter-tool
v0.2.0
Published
Twitter Command Line Tool.simple but flexible interface to access all REST API by short abbreviated commands then easy to re-use data by JSONPath/CSV. JPG/PNG upload support.
Downloads
8
Maintainers
Readme
twitter-tool - Command Line Twitter Client
Twitter Command Line Tool.simple but flexible interface to access all REST API by short abbreviated commands then easy to re-use data by JSONPath/CSV. JPG/PNG upload support.
$ twitter s/up -o 's_n:Photo from twitter-tool!' -m photo.jpg
Install
npm i -g twitter-tool
Command line
twitter [-u <username>] <command> [options]
Twitter Command Line Tool.simple but flexible interface to access all REST API by short abbreviated commands then easy to re-use data by JSONPath/CSV. JPG/PNG upload support.
Copyright (C) 2019-2021 @kssfilo(https://kanasys.com/gtech/)
Options
- h [<command>] show help and command list.if you specify command name, you can see details.
- ? [<command>]
- d debug mode
- D debug mode (+ recipe-js debug messages)
- u <username> specify your user name like @username or username. you can set default by TWITTER_USER environment variable
- g <command> force GET request.command is Twitter REST Api command. e.g. 'search/tweets'. see $ twitter -h
- p <command> force POST request. normally,you don't need to specify -g or -p . twitter-tool guesses method by command
- o <jsonstring> parameters for GET/POST request. JSON format like '{"q":"#nodejs"}'.you can omit outer {} and double quote. e.g 'q:#nodejs,lang:ja'
- e [<depth>] outputs default format(Util.inspect). default depth is 0 or 1(if result is array or few). you can add depth by this option e.g -i 2.
- j [<jsonpath>] outputs JSON format.filters by given JSONPath. you can specify multiple like -j '$.id|$.name'.output will be 2 dimention array in this case. about JSONPath, see https://goessner.net/articles/JsonPath/
- J [<jsonpath>] outputs CSV format(separated by ,) if JSONPath indicate single value, -J output is like a string or value. e.g '$.statuses[0].id' -> 12345689
- l compress output JSON to single line
- r removes all return codes from result.
- O <filename> write results to file (default:stdout)
- m <filename> media file such as jpg/png, you don't need to specify 'media_ids' in -o param. -m option can be specified max 4 times
- T inject Twitter REST API result JSON from stdin instead of accessing Twitter. you can use JSONPath(-j /-J) to parse it. for reusing result or testing purpose
- n does no not anything. (for checking command/params abbreviation.)
- c verify credentials(for checking communication to Twitter server)
- i set up for specified user
- I initialize all data then setup App key again
Examples
tweet
$ twitter -u @yourtwitterid statuses/update -o '{"status":"Hello from twitter-tool!"}'
or (abbreviation)
$ twitter -u yourtwitterid s/up -o 's:Hello from twitter-tool!'
or (environment variable+abbreviation)
$ export TWITTER_USER=yourtwitterid
$ twitter s/up -o 's:Hello from twitter-tool!'
tweet with jpg/png
$ twitter s/up -o 's_n:Photo from twitter-tool!' -m photo.jpg
search and print CSV by JSONPath
$ twitter s/t -o 'q:#nodejs (awesome OR nice)' -rJ $.statuses[*].text
checking timeline and JSON output by JSONPath
$ twitter s/h -rJ '$[*].user.name|$[*].text'
#you can chain JSONPath by '|'
about JSONPath see https://goessner.net/articles/JsonPath/ for more informaton.
you should combine with norl to do more complex JSON processing.
Setup
$ twitter -I
then
$ twitter -u @username -i
Commands (abbreviation)
account/remove_profile_banner (a/r) account/settings (a/s) account/update_profile (account/update_profile)
account/update_profile_banner (a/update_profile_b) account/update_profile_image (a/update_profile_i) account/verify_credentials (a/v)
blocks/create (b/c) blocks/destroy (b/d) blocks/ids (b/i)
blocks/list (b/l) collections/create (c/c) collections/destroy (c/d)
collections/entries (c/e) collections/entries/add (c/e/a) collections/entries/curate (c/e/c)
collections/entries/move (c/e/m) collections/entries/remove (c/e/r) collections/list (co/l)
collections/show (c/s) collections/update (c/u) custom_profiles/:id (c/:id)
custom_profiles/list (cu/l) custom_profiles/new.json (c/n) direct_messages/events/list (d/e/l)
direct_messages/events/new (d/e/n) direct_messages/events/show (d/e/s) direct_messages/indicate_typing (d/i)
direct_messages/mark_read (d/m) direct_messages/welcome_messages/list (d/w/l) direct_messages/welcome_messages/new (d/w/n)
direct_messages/welcome_messages/rules/list (d/w/r/l)direct_messages/welcome_messages/rules/new (d/w/r/n) direct_messages/welcome_messages/rules/show (d/w/r/s)
direct_messages/welcome_messages/show (d/w/s) favorites/create (fa/c) favorites/destroy (fa/d)
favorites/list (fa/l) feedback/create.json (fe/c) feedback/events.json (f/e)
feedback/show/:id.json (f/s/:) followers/ids (fo/i) followers/list (fo/l)
friends/ids (fr/id) friends/list (fr/li) friendships/create (fr/c)
friendships/destroy (fr/d) friendships/incoming (f/in) friendships/lookup (f/lo)
friendships/no_retweets/ids (f/n/i) friendships/outgoing (f/o) friendships/show (f/s)
friendships/update (f/u) geo/id/:place_id (g/i/:) geo/reverse_geocode (g/r)
geo/search (g/s) insights/engagement (i/e) lists/create (l/c)
lists/destroy (l/d) lists/list (l/l) lists/members (lists/members)
lists/members/create (lists/members/create) lists/members/create_all (l/m/create_) lists/members/destroy (lists/members/destroy)
lists/members/destroy_all (l/m/destroy_) lists/members/show (l/m/s) lists/memberships (l/membersh)
lists/ownerships (l/o) lists/show (l/sh) lists/statuses (l/st)
lists/subscribers (l/subscrib) lists/subscribers/create (l/s/c) lists/subscribers/destroy (l/s/d)
lists/subscribers/show (l/s/s) lists/subscriptions (l/subscrip) lists/update (l/u)
mutes/users/create (m/u/c) mutes/users/destroy (m/u/d) mutes/users/ids (m/u/i)
mutes/users/list (m/u/l) oauth/access_token (o/ac) oauth/authenticate (o/authe)
oauth/authorize (o/autho) oauth/invalidate_token (oauth/invalidate_token) oauth/request_token (o/r)
oauth2/invalidate_token (oauth2/i) oauth2/token (o/t) saved_searches/create (s/c)
saved_searches/destroy/:id (sa/d/:id) saved_searches/list (sa/l) saved_searches/show/:id (sa/s/:id)
search/tweets (s/t) statuses/destroy/:id (st/d/:id) statuses/filter (s/f)
statuses/home_timeline (s/h) statuses/lookup (s/lo) statuses/mentions_timeline (s/m)
statuses/oembed (s/o) statuses/retweet/:id (statuses/retweet/:id) statuses/retweeters/ids (s/r/i)
statuses/retweets/:id (s/retweets/:id) statuses/retweets_of_me (s/r) statuses/sample (s/s)
statuses/show/:id (st/s/:id) statuses/unretweet/:id (s/u/:id) statuses/update (s/up)
statuses/user_timeline (s/us) trends/available (t/a) trends/closest (t/c)
trends/place (t/p) users/lookup (u/l) users/profile_banner (u/p)
users/report_spam (u/r) users/search (u/se) users/show (u/sh)
you can see details by $ twitter -h <command or abbreviation>
also refer https://developer.twitter.com/en/docs/api-reference-index
(for using other commands such as Premium/Enterprise search, you can use -g -p option to avoid command / param check.)
Change Log
- 0.1.x: beta release