Preparations

We'll be using two different tools to interact with APIs in this book: HTTPie, which is a command line application, and Postman. Most of the examples can be accomplished using either tool. Feel free to use any other HTTP tool you are familiar with, including those mentioned in our HTTP Book.

Installing HTTPie

Installing and running HTTPie requires a working Python installation. Most Macs and Linux machines will already have a usable version of Python installed and can simply follow the instructions on the HTTPie site.

Windows users can install Python if they don't already have it using the installers released by the Python Software Foundation, and then proceed to install HTTPie using the directions for Windows.

Once you have completed the installation, make sure everything is working by running the following command:

$ http --version
0.8.0

The installed version of HTTPie should print out its version.

If you see command not found or another error message, go back and make sure the installation completed successfully.

This book is written using HTTPie version 0.8.0. Newer versions should be OK, but it is possible that some of the options will have changed.

HTTPie Option Reference

This book will include detailed examples for using the http program provided by HTTPie. The following options for the http command will be used throughout the examples:

Option What it does
-p What to output: H and B for request headers and body, h and b for response headers and body
-a Authenticate with this username:password combination
--help View command options and documentation

HTTPie's built-in help can be viewed by running it with the --help flag:

$ http --help
usage: http [--json] [--form] [--pretty {all,colors,format,none}]
            [--style STYLE] [--print WHAT] [--verbose] [--headers] [--body]
            [--stream] [--output FILE] [--download] [--continue]
            [--session SESSION_NAME_OR_PATH | --session-read-only SESSION_NAME_OR_PATH]
            [--auth USER[:PASS]] [--auth-type {basic,digest}]
            [--proxy PROTOCOL:PROXY_URL] [--follow] [--verify VERIFY]
            [--timeout SECONDS] [--check-status] [--ignore-stdin] [--help]
            [--version] [--traceback] [--debug]
            [METHOD] URL [REQUEST_ITEM [REQUEST_ITEM ...]]

HTTPie - a CLI, cURL-like tool for humans. <http://httpie.org>

...

We'll be going over how to use HTTPie to make requests when we review HTTP.

Installing Postman

Go to the Postman download page and download and install the version of Postman appropriate for your system. There is also a link to a Web version of Postman on that page. Either of these should work, though there may be discrepancies.

Now let's put these new tools to use.