twurl
Interact with Twitter via command line
TLDR
Authorize twurl to access a Twitter account
Make a GET request to an API endpoint
Make a POST request to an API endpoint
Upload media to Twitter
Access a different Twitter API host
Create an alias for a requested resource
SYNOPSIS
twurl
[options] <path> [parameters]twurl
authorizetwurl
accountstwurl
config <key> <value>
PARAMETERS
-X
, --request
<METHOD>
Specify the HTTP request method (e.g., GET, POST, PUT, DELETE). Default is GET.-H
, --header
<HEADER>
Pass custom header(s) to the request in the format "Header: Value".-d
, --data
<DATA>
HTTP POST data for the request (e.g., "status=Hello+World").-A
, --auth
<METHOD>
Specify the authentication method to use (e.g., oauth
, bearer
).-u
, --user
<USERNAME>
Use a specific user's credentials if multiple accounts are configured.-P
, --profile
<PROFILE>
Specify a profile name to use from the configuration.-v
, --verbose
Make the operation more talkative, showing request details.-s
, --silent
Don't show progress meter or error messages.-t
, --trace
Show detailed HTTP request and response headers and body.--consumer-key
<KEY>
Override the configured consumer key for the current request.--consumer-secret
<SECRET>
Override the configured consumer secret for the current request.--token
<TOKEN>
Override the configured access token for the current request.--secret
<SECRET>
Override the configured access token secret for the current request.--bearer
<TOKEN>
Use a specified bearer token for application-only authentication.--version
Show version number and exit.--help
Show help message and exit.--clear-cache
Clear the authentication cache for all users.--no-cache
Do not use the authentication cache for the current request.--proxy
<PROXY_URL>
Use the specified proxy for HTTP requests.--config
<FILE>
Use an alternative configuration file instead of the default.--daemon
Run twurl
as a daemon for streaming API endpoints.--json-stream
Parse incoming JSON stream and pretty-print each JSON object.--rate-limit
Show Twitter API rate limit information for the requested endpoint.--user-cache
<PATH>
Use a specific path for user credentials cache.
DESCRIPTION
twurl
is a powerful command-line tool that provides a convenient interface for interacting with the Twitter API. Developed by Twitter engineers, it simplifies the process of making authenticated requests by handling the OAuth 1.0a and OAuth 2.0 authentication flows automatically. Users can easily send HTTP requests (GET, POST, PUT, DELETE) to any Twitter API endpoint, making it ideal for testing, debugging, and scripting interactions with Twitter. It abstracts away the complexities of signing requests, allowing developers to focus on the API endpoints and parameters. twurl
is particularly useful for exploring the Twitter API, quickly prototyping applications, or performing administrative tasks without needing to write extensive code. It supports various authentication methods including user-based OAuth and application-only bearer tokens.
CAVEATS
Twitter API Changes:
The Twitter API (now known as the X API) undergoes frequent changes (e.g., v1.1 vs. v2), which may affect the behavior or availability of certain endpoints used with twurl
.
Rate Limits:
All requests to the Twitter API are subject to strict rate limits. Exceeding these limits can result in temporary blocking of your application or user account.
Deprecation:
Older API versions, features, or endpoints might be deprecated and eventually removed by Twitter, requiring users to update their twurl
commands and scripts.
INSTALLATION
twurl
is typically installed as a Ruby gem: gem install twurl
It requires Ruby to be installed on your system.
AUTHENTICATION
Before making authenticated requests, you usually need to authorize twurl
. This is commonly done with: twurl authorize
This command will open a browser window for you to grant access to your Twitter account and then prompt for a verification PIN. Alternatively, you can manually configure consumer keys and secrets using twurl config
.
HISTORY
twurl
was developed by Twitter engineers, primarily for internal use, and was later released as an open-source Ruby gem. Its primary motivation was to simplify interaction with the complex and evolving Twitter API, especially handling the intricacies of OAuth 1.0a authentication. It quickly gained popularity among developers and scripters for its ease of use in testing API endpoints, debugging issues, and automating Twitter interactions directly from the command line, without needing to write full-fledged applications. Its continuous development reflects ongoing changes and additions to the Twitter API.