Skip to main content

# Python Code Examples

This will guide you through the steps necessary to set up credentials and start playing with the sample code. Note that once you’ve set up credentials for one language, you don’t need to re-create them for another language. If you set up the credentials for python, php will use the same credentials.

These instructions expect that you are in the examples/python subdirectory of the github repository.

# Authentication and Provisioning The easiest way to walk through the needed provisioning and authentication to get your credentials is by following the instructions on [Authorizing your Client](https://developer.akamai.com/introduction/Prov_Creds.html) from the Getting started guide on our site. Once you have done this, you’ll be able to run the ‘diagnostic tools’ example scripts.

## Credential File Creation You can get your credentials set up for use by the sample code by using the gen_edgerc.py command in the examples/python directory: `bash $ ./gen_edgerc.py `

When you run gen_edgerc.py with no command line options, the script will create a ‘default’ section in your ~/.edgerc file. For examples other than diagnostic_tools.py you’ll need to pass the name of the appropriate section as an argument, for example this is how you’d set up ccu.py: `bash ./gen_edgerc.py ccu `

You can find the correct name for the credentials section on the “section=” line in the example script. If you run the script again for a specific section (including ‘default’) it will overwrite the previous credentials with your new ones.

## Diagnostic Tools - diagnostic_tools.py The first example code to test is the diagnostic_tools.py script. The credentials from the creation step give you permission to run the “dig” command from the API.

` bash ./diagnostic_tools.py `

This simple script runs the ‘locations’ call to find out where the Akamai servers are located. The API can run the ‘dig’ for you from any of these locations. Once it has done that, it grabs one at random and makes the dig call from there.

By reviewing the code you can see how simple it is to make API calls.

All of the sample code in the directory also supports –verbose to see the output on the screen, and/or –debug to see all of the HTTP traffic. These flags can help enormously in figuring out what’s going wrong or how it’s working.

` bash ./diagnostic_tools.py --verbose ./diagnostic_tools.py --debug `

## CCU (Purge) - ccu.py We have a [blog post](https://community.akamai.com/community/developer/blog/2015/08/20/getting-started-with-the-v2-open-ccu-api) with instructions on getting set up with the CCU API. Prerequisites: ccu credentials and edit the filename to a valid file on your system

Metadata

Release files for akamaikickstart 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for akamaikickstart 1.0.0
File Size Uploaded
akamaikickstart-1.0.0.tar.gz 2.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for akamaikickstart 1.0.0
File Interpreter ABI Platform
akamaikickstart-1.0.0-py2-none-any.whl Python 2 none any Details

Total release size: 4.1 kB

Release files / akamaikickstart-1.0.0.tar.gz

Download URL akamaikickstart-1.0.0.tar.gz
Size 2.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b51b68c8e8199e7d86caeb0532cf9d138216e09cc353b733e26438486920dbe2
BLAKE2b-256 checksum
How to use checksums
e89c6df0a123faa8bb68763c78fe6c03e9a59ff46613e31e082b7c0bf5605a5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / akamaikickstart-1.0.0-py2-none-any.whl

Download URL akamaikickstart-1.0.0-py2-none-any.whl
Size 2.0 kB
Tags Python 2
SHA-256 checksum
How to use checksums
1a151a22fdd1d52bd6687ab4c0c71f1feb5d97fd8cf12f4b5679f4897dd92752
BLAKE2b-256 checksum
How to use checksums
9e89708a9f1257d8a4f4d82837d16f7e738a048b11150bb4e8f4e199ff30bc9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page