NetDNA / MaxCDN REST API Private Beta signup

Introduction

The NetDNA API[1] is an XML-RPC[2] based programming interface for many of the most common functions found in the NetDNA Control Panel.

The API includes important functions to create, modify, prime and purge cache files, list and update users, and create all of the various reports.

To use the NetDNA API, you must have a NetDNA account, an API Key, an API user id, and the xmlrpc library installed. These are all described in more detail below along with complete documentation of all the API methods and their parameters. Sample scripts are included later in this document to make using the API as easy as possible.

Authentication

The functionality offered through the XML-RPC API requires NetDNA API user authentication.

Generate API Key and API User ID

In order to use the NetDNA Public API, developers must first generate a unique API Key and API User ID. To generate these, login to the NetDNA Control Panel, navigate to the Manage Account > API section and press the button labeled “Add API key” and a API Key and API User ID will be generated for you.

 

Request Parameters

All requests to the XML-RPC web services require authorization. Developers may gain access to the web services by generating an API Key and API User Id as detailed in the previous section. An apiUserId, authString and currentDate must be sent as a parameter with every XML-RPC method call.

  • int apiUserId — A unique key required for each developer to access any XML-RPC method
  • string authString — A unique authentication string required for each developer to access any XML-RPC method
  • string currentDate — An ISO 8601 formatted date/time in America/Los Angeles time (PST/PDT), e.g. 2010-02-12T15:19:21-07:00

authString

An authString is a unique authentication string required for each developer to access any XML-RPC method call. It is a sha256 hash of the following string format:

 

Where:

  • currentDate (string) — is an ISO 8601 formatted string of the current date/time in America/Los Angeles time (PST/PDT). This is based on PHP 5′s date(‘c’) output. Example: 2010-08-25T10:13:16-07:00
  • apiKey (string) — is the API User Key generated through the control panel
  • method (string) — is the XML-RPC method to invoke (without the namespace)

Note: Before getting the current date you will need to set your timezone to America/Los_Angeles. The API only executes calls with an authString generated within the last 10 minutes. You will see how to set the timezone in our sample codes section.

Sample authString generation code

 

Sample Code

To make it easy to get started, we have included sample API scripts.

[box type="info"]We also have sample PHP code on github here: http://j.mp/github-netdna-api[/box]

PHP

You will need to have the xmlrpc library installed on your machine in order to use the API code with PHP. The xmlrpc library is part of phpxmlrpc which is an open source package that can be downloaded from http://sourceforge.net/projects/phpxmlrpc/files/phpxmlrpc/2.2.2/xmlrpc-2.2.2.tar.gz/download. The include library, xmlrpc.inc, is part of the package. Just extract the file and xmlrpc.inc will be located inside the lib folder.

[box type="info"]Find complete NetDNA™ PHP API Example on GitHub[/box]

Python

ASP.NET

We are aware of an issues regarding the API “Date” being incorrect due to daylight savings time. We are not ASP experts so this code will need to be slightly tweaked. Making the code DST aware has solved the issue for our customers:

 

Data Types

Common Data Types

  • array — Array of values, storing no keys
  • base64 — base64 encoded binary data
  • boolean — logical value (0 or 1)
  • date/time — Date and time in ISO 8601 format
  • double — double precision floating point number
  • integer — Whole number, integer
  • string — string of characters, must follow XML encoding
  • struct — associative array
  • nil — discriminative null value

Common Structs

1. struct pullzone (

  • int id
  • string name
  • string origin
  • string vhost
  • string ip
  • string compress
  • string vanity_domain
  • string vanity_ip

)

2. struct pushzone (

  • int id
  • string name
  • string vanity_domain
  • string vanity_ip
  • string storage_location

)

3. struct vodzone (

  • int id
  • string name
  • string storage_location

)

API Methods

A list of all the available XML-RPC API methods are included in the following sections.

Pull Zones

API URL

All XML-RPC requests should go to the following URL: http://api.netdna.com/xmlrpc/pullzone

pullzone.create

Description

pullzone.create – Creates a new Pull Zone on the edge servers. This type of zone caches content on the edge servers and pulls from the customer’s origin server as needed.

Method Signature

Parameters

  • int apiUserId — the API user id
  • string authString — used for server validation
  • string currentDate — ISO 8601 formatted date
  • struct values– A pullzone struct
    • string name
    • string origin
    • string vhost (optional)
    • string ip (optional)
    • string compress (optional)
    • string vanity_domain (optional)
    • string label (optional)

Return Values

On Success

On Error

array ( int errorCode, string errorString )

  • errorCode: 2001
    • errorString: Pull Zone creation failed
  • errorCode: 2002
    • errorString:is already in use
  • errorCode: 2003
    • errorString:does not resolve

pullzone.update

Description

pullzone.update – Updates an existing Pull Zone

Method Signature

Parameters

  • int apiUserId — the API user id
  • string authString — used for server validation
  • string currentDate — ISO 8601 formatted date
  • int id — the id of the zone to update
  • struct values– A key/value pair that contains the new zone settings
    • string name (optional)
    • string origin (optional)
    • string vhost (optional)
    • string ip (optional)
    • string compress (optional)
    • string label (optional)

Return Values

Returns 0 if the update is a success, 1 if otherwise

pullzone.listZones

Description

pullzone.listZones – Lists all Pull Zones from an account

Method Signature

Parameters

  • int apiUserId — the API user id
  • string authString — used for server validation
  • string currentDate — ISO 8601 formatted date

Return Values

An array of pullzones


Push Zones

API URL

All XML-RPC requests should go to the following URL: http://api.netdna.com/xmlrpc/pushzone

pushzone.create

Description

pushzone.create – Creates a new Push Zone.

Method Signature

Parameters

  • int apiUserId — the API user id
  • string authString — used for server validation
  • string currentDate — ISO 8601 formatted date
  • struct values– a pushzone struct
    • string name
    • string password
    • string compress (optional)
    • string vanity_domain (optional)
    • string label (optional)

Return Values

On Success

On Error

array ( int errorCode, string errorMessage )

  • errorCode: 3001
    • errorString: Push Zone creation failed
  • errorCode: 3002
    • errorString:is already in use

pushzone.update

Description

pushzone.update — Updates an existing Push Zone

Method Signature

Parameters

  • int apiUserId — the API user id
  • string authString — used for server validation
  • string currentDate — ISO 8601 formatted date
  • int id — the id of the zone to update
  • struct values
    • string name (optional)
    • string password (optional)
    • string label (optional)

Return Values

Returns 0 if the update is a success, 1 if otherwise

pushzone.listZones

Description

pushzone.listZones — Lists all Push Zones from an account

Method Signature

Parameters

  • int apiUserId — the API user id
  • string authString — used for server validation
  • string currentDate — ISO 8601 formatted date

Return Values

An array of pushzones


VOD Zones

API URL

All XML-RPC requests should go to the following URL: http://api.netdna.com/xmlrpc/vodzone

vodzone.create

Description

vodzone.create – Create a new VOD Zone.

Method Signature

Parameters

  • int apiUserId — the API user id
  • string authString — used for server validation
  • string currentDate — ISO 8601 formatted date
  • struct values
    • string name
    • string password
    • string label (optional)

Return Values

On Success

On Error

  • errorCode: 4001
    • errorString: VOD Zone creation failed
  • errorCode: 4002
    • errorString: is already in use

vodzone.update

Description

vodzone.update — Updates an existing Vod Zone

Method Signature

Parameters

  • int apiUserId — the API user id
  • string authString — used for server validation
  • string currentDate — ISO 8601 formatted date
  • int id — the id of the zone to update
  • struct values
    • string name (optional)
    • string password (optional)
    • string label (optional)

Return Values

Returns 0 if the update is a success, 1 if otherwise

vodzone.listZones

Description

vodzone.listZones — Lists all Vod Zones from an account

Method Signature

Parameters

  • int apiUserId — the API user id
  • string authString — used for server validation
  • string currentDate — ISO 8601 formatted date

Return Values

An array of vodzones


 

Live Zones

NOTE: The Live Zone API is available only by request. We can give access to the livezone api calls per api key.

API URL

All XML-RPC requests should go to the following URL: http://api.netdna.com/xmlrpc/livezone

livezone.create

Description

livezone.create – Create a new Live Zone.

Method Signature

Parameters

  • int apiUserId — the API user id
  • string authString — used for server validation
  • string currentDate — ISO 8601 formatted date
  • struct values
    • string name
    • string password
    • string label (optional)

Return Values

On Success

On Error

  • errorCode: 5001
    • errorString: Live Zone creation failed
  • errorCode: 5002
    • errorString:is already in use

livezone.update

Description

livezone.update — Updates an existing Live Zone

Method Signature

Parameters

  • int apiUserId — the API user id
  • string authString — used for server validation
  • string currentDate — ISO 8601 formatted date
  • int id — the id of the zone to update
  • struct values
    • string name (optional)
    • string password (optional)
    • string label (optional)

Return Values

Returns 0 if the update is a success, 1 if otherwise

livezone.delete

Description

livezone.delete — Deletes an existing Live Zone

Method Signature

Parameters

  • int apiUserId — the API user id
  • string authString — used for server validation
  • string currentDate — ISO 8601 formatted date
  • int id — the id of the zone to delete

Return Values

Returns 0 if delete is a success, 1 if otherwise

livezone.listZones

Description

livezone.listZones — Lists all Live Zones from an account

Method Signature

Parameters

  • int apiUserId — the API user id
  • string authString — used for server validation
  • string currentDate — ISO 8601 formatted date

Return Values

An array of livezones


Cache

The methods to purge cache are listed in this section.

API URL

All XML-RPC requests should go to the following URL: http://api.netdna.com/xmlrpc/cache

cache.purge

Description

cache.purge – Purges a file from cache so it is pulled from the origin server the next time it is requested.

Method Signature

Parameters

  • int apiUserId — the API user id
  • string authString — used for server validation
  • string currentDate — ISO 8601 formatted date
  • string url — url of the file to purge from cache

Return Values

Returns TRUE if purging is successful, FALSE if otherwise.

cache.purgeAllCache

Description

cache.purgeAllCache – Purges a file from cache so it is pulled from the origin server the next time it is requested.

Method Signature

Parameters

  • int apiUserId — the API user id
  • string authString — used for server validation
  • string currentDate — ISO 8601 formatted date
  • string zone — The name of the zone to purge

Return Values

Returns TRUE if purging is successful, FALSE if otherwise.

User

API URL

All XML-RPC requests should go to the following URL: http://api.netdna.com/xmlrpc/user

user.listUsers

Description

user.listUsers – Lists all users from an account

Method Signature

Parameters

  • int apiUserId — the API user id
  • string authString — used for server validation
  • string currentDate — ISO 8601 formatted date

Return Values

Array of users

user.update

Description

user.update – Modifies user information

Method Signature

Parameters

  • int apiUserId — the API user id
  • string authString — used for server validation
  • string currentDate — ISO 8601 formatted date
  • int id — the id of the user to update
  • struct values – The key/value pair for the new user settings

Return Values

array


Account

API URL

All XML-RPC requests should go to the following URL: http://api.netdna.com/xmlrpc/account

account.getBandwidth

Description

account.getBandwidth – Gets prepaid bandwidth remaining

Method Signature

Parameters

  • int apiUserId — the API user id
  • string authString — used for server validation
  • string currentDate — ISO 8601 formatted date
  • string from — (optional) start date (Format: Y-m-d, Example: 2009-11-10)
  • string to — (optional) end date (Format: Y-m-d, Example: 2010-11-10)

Return Values

The remaining prepaid bandwidth


Report

API URL

All XML-RPC requests should go to the following URL: http://api.netdna.com/xmlrpc/report

report.getTotalTransfer

Description

report.getTotalTransfer – Returns the total bandwidth transfer for a given Zone ID and date range

Method Signature

Parameters

  • int apiUserId
  • string authString
  • string currentDate
  • int zoneId — the Zone ID
  • int type — 1=today, 2=current hour, 3=date range
  • string from — (optional if type=1 or type=2) starting date (Format: Y-m-d, Example: 2010-08-01)
  • string to — (optional if type=1 or type=2) end date (Format: Y-m-d, Example: 2010-08-30)
  • string timezone — (optional)

Return Values

array

report.getTotalHits

Description

report.getTotalHits – Get total hits for a given Zone ID and date range

Method Signature

Parameters

  • int apiUserId
  • string authString
  • string currentDate
  • int zoneId — the Zone ID
  • int type — 1=current date, 2=current hour, 3=date range
  • string from — (optional if type=1 or type=2) start date (Format: Y-m-d, Example: 2010-08-01)
  • string to — (optional if type=1 or type=2) end date (Format: Y-m-d, Example: 2010-08-30)
  • string timezone — (optional)

Return Values

array

report.getTotalTransferStats

Description

report.getTotalTransferStats – Returns transfer stats for a given company/zone and date range

Method Signature

Parameters

  • int apiUserId
  • string authString
  • string currentDate
  • mixed companyId — your unique company id or company alias
  • string dateFrom — start date (Format: Y-m-d, Example: 2010-08-01)
  • string dateTo — end date (Format: Y-m-d, Example: 2010-08-30)
  • int zoneId — the Zone ID
  • array sortby — (optional) an array of “column sortorder” strings, please see returned columns for possible values. sortorder can be ASC or DESC.
  • string viewby — (optional) hourly or daily
  • int maxReturn — (optional) the maximum number of records to return
  • string offset — (optional) the offset of the first row to return, the first record is always 0
  • string timezone — (optional)

Return Values

array

report.getCacheHitStats

Description

report.getCacheHits – Returns the total cache hits for a given company/zone and date range

Method Signature

Parameters

  • int apiUserId
  • string authString
  • string currentDate
  • mixed companyId — your unique company id or company alias
  • string dateFrom — start date
  • string dateTo — end date
  • int zoneId — the Zone ID
  • array sortby — (optional) an array of “column sortorder” strings, please see returned columns for possible values. sortorder can be ASC or DESC.
  • int maxReturn — (optional) the maximum number of records to return
  • int offset — (optional) the offset of the first row to return, the first record is always 0
  • string timezone — (optional)

Return Values

int

report.getPopularFiles

Description

array report.getPopularFiles – Returns a list of popular files for a given company/zone and date range

Method Signature

Parameters

  • int apiUserId
  • string authString
  • string currentDate
  • mixed companyId — your unique company id or company alias
  • string dateFrom — start date
  • string dateTo — end date
  • int zoneId — the Zone ID
  • array sortby — (optional) an array of “column sortorder” strings, please see returned columns for possible values. sortorder can be ASC or DESC.
  • int maxReturn — (optional) the maximum number of records to return
  • int offset — (optional) the offset of the first row to return, the first record is always 0

Return Values

array

report.getUsagePerDay

Description

report.getUsagePerDay – Returns usage stats for a give company/zone and date range

Method Signature

Parameters

  • int apiUserId
  • string authString
  • string currentDate
  • mixed companyId — your unique company id or company alias
  • string dateFrom — start date
  • string dateTo — end date
  • int zoneId — the Zone ID
  • array sortby — (optional) an array of “column sortorder” strings, please see returned columns for possible values. sort order can be ASC or DESC.
  • int maxReturn — (optional) the maximum number of records to return
  • int offset — (optional) the offset of the first row to return, the first record is always 0

Return Values

int

report.getNodeHits

Description

report.getNodeHits – returns a list of node hits for a given company/zone and date range

Method Signature

Parameters

  • int apiUserId
  • string authString
  • string currentDate
  • mixed companyId — your unique company id or company alias
  • string dateFrom — start date
  • string dateTo — end date
  • int zoneId — the Zone ID
  • array sortby — (optional) an array of “column sortorder” strings, please see returned columns for possible values. sortorder can be ASC or DESC.
  • int maxReturn — (optional) the maximum number of records to return
  • int offset — (optional) the offset of the first row to return, the first record is always 0

Return Values

array

report.getConnectionStats

Description

report.getConnectionStats – returns a list of live zone daily connection stats for a given company/zone and date range

Method Signature

Parameters

  • int apiUserId
  • string authString
  • string currentDate
  • mixed companyId — your unique company id or company alias
  • string dateFrom — start date
  • string dateTo — end date
  • int zoneId — the Zone ID
  • array sortby — (optional) an array of “column sortorder” strings, please see returned columns for possible values. sortorder can be ASC or DESC.
  • int maxReturn — (optional) the maximum number of records to return
  • int offset — (optional) the offset of the first row to return, the first record is always 0
  • string timezone — (optional)

Return Values

array

report.getHourlyConnectionStats

Description

report.getHourlyConnectionStats – returns a list of live zone hourly connection stats for a given company/zone and date

Method Signature

Parameters

  • int apiUserId
  • string authString
  • string currentDate
  • mixed companyId — your unique company id or company alias
  • string dateFrom — the date to fetch hourly stats from
  • int zoneId — the Zone ID
  • array sortby — (optional) an array of “column sortorder” strings, please see returned columns for possible values. sortorder can be ASC or DESC.
  • int maxReturn — (optional) the maximum number of records to return
  • int offset — (optional) the offset of the first row to return, the first record is always 0
  • string timezone — (optional)

Return Values

array

[/box]