Request URL
The only information HTTPie needs to perform a request is a URL.The default scheme is, somewhat unsurprisingly, http://,and can be omitted from the argument – http example.org works just fine.
Querystring parameters
If you find yourself manually constructing URLs with querystring parameterson the terminal, you may appreciate the param==value syntax for appendingURL parameters.
With that, you don't have to worry about escaping the &separators for your shell. Additionally, any special characters in theparameter name or value get automatically URL-escaped(as opposed to parameters specified in the full URL, which HTTPie doesn’tmodify).
- $ http https://api.github.com/search/repositories q==httpie per_page==1
- GET /search/repositories?q=httpie&per_page=1 HTTP/1.1
URL shortcuts for localhost
Additionally, curl-like shorthand for localhost is supported.This means that, for example :3000 would expand to http://localhost:3000If the port is omitted, then port 80 is assumed.
- $ http :/foo
- GET /foo HTTP/1.1
- Host: localhost
- $ http :3000/bar
- GET /bar HTTP/1.1
- Host: localhost:3000
- $ http :
- GET / HTTP/1.1
- Host: localhost
Other default schemes
When HTTPie is invoked as https then the default scheme is https://($ https example.org will make a request to https://example.org).
You can also use the —default-scheme <URL_SCHEME> option to createshortcuts for other protocols than HTTP (possibly supported via plugins).Example for the httpie-unixsocket
- # Before
- $ http http+unix://%2Fvar%2Frun%2Fdocker.sock/info
- # Create an alias
- $ alias http-unix='http --default-scheme="http+unix"'
- # Now the scheme can be omitted
- $ http-unix %2Fvar%2Frun%2Fdocker.sock/info