HTTPie

Overview

If you’re a Web Developer or DevOps, you probably have to deal with several API systems daily. HTTPie allows you to easily explore APIs before you decide if it’s worth to spend the effort to code a client using a programming language like Python, Ruby, Go, etc.

If you’re not already using HTTPie with Akamai, see this excellent post for instructions: Exploring Akamai APIs from the command line using HTTPie and jq.

Once you’re up and running, open the HTTPie configuration file located at ~/.httpie/config.json (or %APPDATA%\httpie\config.json on Windows).

NOTE: The config directory location can be changed by setting the HTTPIE_CONFIG_DIR environment variable. To view the exact location run http –debug.

 

Edit the Configuration File

To make HTTPie work better with Akamai systems, edit the file to match the following:

{
    "__meta__": {
        "about": "HTTPie configuration file",
        "help": "https://github.com/jkbrzt/httpie#config",
        "httpie": "0.9.9"
    },

    "default_options": [
        "--verbose",
        "--traceback",
        "--auth-type=edgegrid",
        "--print=Hhb",
        "--timeout=300",
        "--style=autumn",
        "--session-read-only","~/.httpie-custom-headers.json",
        "-adefault:"
    ]
}

Configuration Options

The lines in bold text are the default options you can configure. Here’s what they do:

--auth-type=edgegrid

If you installed the httpie-edgegrid package using “git clone https://github.com/akamai-open/httpie-edgegrid.git” (or "pip install httpie-edgegrid" if you have python), you can put the parameter on the config file to have it indicated by default so instead of calls like:

http --auth-type=edgegrid :/diagnostic-tools/v1/locations

you can run:

http :/diagnostic-tools/v1/locations

--timeout=300

By default HTTPie’s timeout is 30 seconds. Unfortunately, some API calls may take over 30s, so it is always good to have a higher timeout.

--session-read-only","~/.httpie-custom-headers.json"

Allows adding the Akamai debug headers to each HTTPie outgoing request. See "Using Akamai Pragma headers to investigate or troubleshoot Akamai content delivery" for more information about using the Pragma headers.

The file ~/.httpie-custom-headers.json will contain the following:

{
"headers": {
"Pragma": "akamai-x-cache-on, akamai-x-get-cache-key,
akamai-x-check-cacheable, akamai-x-get-true-cache-key,
akamai-x-get-request-id, akamai-x-cache-remote-on"
            }
}

-adefault:

Tells HTTPie to use the default credentials section within .edgerc when no section (-a parameter) is present.

 

HTTPie Resources

Download Documentation