HTTPie
HTTPie is a simple command-line client you can use to make Akamai API calls.
Akamai Docker Development Environment
We've bundled several tools together, including
HTTPie
, to make it easier for you to start testing Akamai APIs. Check out the Docker section for more information.
If you prefer to use HTTPie standalone, follow these steps.
Install HTTPie
To simplify the install process, you can use pip
. It works on Linux, macOS, and Windows, and always provides the latest version of HTTPie. pip
is already installed on Python v3.6 or later. You can download the latest version from python.org.
-
Run the command for your operating system to verify that
pip
is installed:- Linux or macOS
$ python[python3] -m pip --version pip X.Y.Z from .../site-packages/pip (python X.Y)
- Windows
C:\> py -m pip --version pip X.Y.Z from ...\site-packages\pip (python X.Y)
-
Run the command for your operating system to install HTTPie and upgrade it to the most recent version:
- Linux or macOS
$ python -m pip install --upgrade httpie
- Windows
C:\> py -m pip install --upgrade httpie
- Linux or macOS
-
Run this command to install the
httpie-edgegrid
plugin.
This is necessary to authenticate API calls. It's already included in thepip
repo, so you can quickly install it.pip install httpie-edgegrid
-
Run this command to verify the installation and check the version:
pip show httpie-edgegrid
Authenticate
If you haven't already, you'll need to Create authentication credentials.
The httpie-edgegrid
plugin relies on an .edgerc
file to authenticate requests. If you need help setting up your .edgerc
file, refer to Add credential to .edgerc file.
Make API calls with HTTPie
Once you've set up EdgeGrid authentication, you can make API calls with HTTPie.
HTTPie follows a generic path to authenticate and make requests to Akamai APIs:
$ http --auth-type=edgegrid -a default: :{akamai_api-endpoint}
-
auth-type=edgegrid
. Tells the request to useedgegrid
for authentication. -
-a default
. Tells the request to reference the[default]
section of your.edgerc
file for credentials. -
{akamai-api-endpoint}
. This endpoint corresponds to the specific API operation you want to call. You can find a list and explanation of available endpoints in the API documentation.
In this exercise, you'll use HTTPie to look up an IP address with the Edge Diagnostics API.
-
Request the locations of servers in the Akamai network that can run the diagnostic tools.
$ http --auth-type=edgegrid -a default: :/edge-diagnostics/v1/edge-locations
The
200 OK
response shows the location results:HTTP/1.1 200 OK Connection: keep-alive Content-Length: 6524 Content-Type: application/json;charset.UTF-8 Date: Mon, 25 Jun 2018 18:39:57 GMT Server: Apache-Coyote/1.1 X-Trace-Id: c0545b3136fb13bb6 { "edgeLocations": [ { "id": "buenosaires-argentina", "value": "Buenosaires, Argentina" }, { "id": "adelaide-sa-australia", "value": "Adelaide, SA, Australia" }, { "id": "brisbane-qld-australia", "value": "Brisbane, QLD, Australia" }, { "id": "perth-wa-australia", "value": "Perth, WA, Australia" } ] }
-
Request IP address information for Perth, WA, Australia, using the specific
id
from the previous call,perth-wa-australia
.$ http --auth-type=edgegrid -a default: :/edge-diagnostics/v1/dig?locationId=perth-wa-australia&hostName=www.example.com&queryType=A
The
200 OK
response shows location-specific results:HTTP/1.1 200 OK Connection: keep-alive Content-Length: 3073 Content-Type: application/json;charset.UTF-8 Date: Mon, 25 Jun 2018 18:49:48 GMT Server: Apache-coyote/1.1 X-RateLimit-Limit: 10 X-Ratelimit-Remaining: 9 X-Trace-Id: 68585b31394a1a20b { "digInfo": "answerSection": [ { "domain": "example.com.", "preferenceValue": null, "recordClass": "IN", "recordType": "CNAME", "ttl": 300, "value": "example.com.edgekey.net." }, { "domain": "example.com.edgekey.net.", "preferenceValue": null, "recordClass": "IN", "recordType": "CNAME", "ttl": 300, "value": "e24856.dscx.akanmiedgeonet." } ] } }
Video demo
Here's a video demonstration of the process to make API calls with HTTPie.
Updated 29 days ago