Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A Python REST Client for NetDNA REST Web Services
Python Shell
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.

We're Hiring!

Do you like building cool stuff? Do APIs keep you up at night? We're looking for our next superstar hacker and you could be it. Interested? Check out our job posting on stackoverflow.

NetDNA REST Web Services Python Client


sudo pip install requests

sudo pip install certifi


sudo pip install netdnarws


from netdnarws import NetDNA

api = NetDNA("myalias", "consumer_key", "consumer_secret")

# Get Account Info

# Create Pull Zone"/zones/pull.json", {'name': 'mypullzone', 'url': '', 'compress': '1'})

# Update Pull Zone
api.put("/zones/pull.json/12345", {'url': ''})

# Purge All Cache

# Purge File
api.delete("/zones/pull.json/77573/cache", data={'file': '/my-file.png'})


It has support for GET, POST, PUT and DELETE OAuth signed requests.

We now have a shortcut for Purge Calls!

zone_id = 12345

# Purge Zone

# Purge File
api.purge(zone_id, '/some_file')

# Purge Files
api.purge(zone_id, ['/some_file', '/another_file'])

Every request can take an optional debug parameter.

api.get("/account.json", debug=True)
# Will output
# Making GET request to
#{... API Returned Stuff ...}

Every request can also take an optional debug_json parameter if you don't like the exception based errors.
api.get('/account.json', debug_json=True)

For more information about what optional parameters this methods accept you should check out @kennethreitz library Requests.


For applications that don't require user authentication, you can use the default initialization as the example above.

For applications that require user authentication, you can initialize the API as follows.

api = NetDNA("myalias", "consumer_key", "consumer_secret",
             token="user_token", token_secret="user_token_secret")

You can also send the optional parameter header_auth, which takes a boolean to send the OAuth header in the body or URLEncoded.

Something went wrong with that request. Please try again.