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


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-2019 @kssfilo(


- 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
- 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



$ 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 '$[*]|$[*].text'
#you can chain JSONPath by '|'

about JSONPath see for more informaton.

you should combine with norl to do more complex JSON processing.


$ twitter -I


$ twitter -u @username -i

Commands (abbreviation)

account/settings (a/s)                               account/update_profile_banner (a/update_profile_b)   account/verify_credentials (a/v)                     
blocks/destroy (b/d)                                 blocks/list (b/l)                                    collections/destroy (c/d)                            
collections/entries/add (c/e/a)                      collections/entries/move (c/e/m)                     collections/list (co/l)                              
collections/update (c/u)                             custom_profiles/list (cu/l)                          direct_messages/events/list (d/e/l)                  
direct_messages/events/show (d/e/s)                  direct_messages/mark_read (d/m)                      direct_messages/welcome_messages/new (d/w/n)         
direct_messages/welcome_messages/rules/new (d/w/r/n) direct_messages/welcome_messages/show (d/w/s)        favorites/destroy (fa/d)                             
feedback/create.json (fe/c)                          feedback/show/:id.json (f/s/:)                       followers/list (fo/l)                                
friends/list (fr/li)                                 friendships/destroy (fr/d)                           friendships/lookup (f/lo)                            
friendships/outgoing (f/o)                           friendships/update (f/u)                             geo/reverse_geocode (g/r)                            
insights/engagement (i/e)                            lists/destroy (l/d)                                  lists/members (lists/members)                        
lists/members/create_all (l/m/create_)               lists/members/destroy_all (l/m/destroy_)             lists/memberships (l/membersh)                       
lists/show (l/sh)                                    lists/subscribers (l/subscrib)                       lists/subscribers/destroy (l/s/d)                    
lists/subscriptions (l/subscrip)                     mutes/users/create (m/u/c)                           mutes/users/ids (m/u/i)                              
oauth/access_token (o/ac)                            oauth/authorize (o/autho)                            oauth/request_token (o/r)                            
oauth2/token (o/t)                                   saved_searches/destroy/:id (sa/d/:id)                saved_searches/show/:id (sa/s/:id)                   
statuses/destroy/:id (st/d/:id)                      statuses/home_timeline (s/h)                         statuses/mentions_timeline (s/m)                     
statuses/retweet/:id (statuses/retweet/:id)          statuses/retweets/:id (s/retweets/:id)               statuses/sample (s/s)                                
statuses/unretweet/:id (s/u/:id)                     statuses/user_timeline (s/us)                        trends/closest (t/c)                                 
users/lookup (u/l)                                   users/report_spam (u/r)                              users/show (u/sh)

you can see details by $ twitter -h <command or abbreviation>

also refer

(for using other commands such as Premium/Enterprise search, you can use -g -p option to avoid command / param check.)

Change Log

Popular Articles from This Page

Top Page

Economizing Technology > twitter-tool - Command Line Twitter Client