API Documentation

Overview

Welcome to the CDNify API documentation. This API allows you to manage your resources easily and efficiently. You can access it at https://cdnify.com/api/v1/resources.

Authentication

Authentication with the API uses HTTP BASIC. The username is your API key (which you can find in the account settings page of your dashboard), and the password is 'x'.

For example: api_key:x

Sample Response

The API supports create, read, update, and delete endpoints for working with your resources. Most API requests will respond with a HTTP status code and this format (unless otherwise stated):

{
    "resources": [{
        "id": "71ab161",
        "alias": "cdnify",
        "origin": "www.cdnify.com",
        "hostname": "cdnify.a.cdnify.io",
        "created_at": "2014-04-28T11:19:28+00:00",
        "custom_domains": []
    }, {
        "id": "b0cd4e9",
        "alias": "igniso",
        "origin": "www.igniso.com",
        "hostname": "igniso.a.cdnify.io",
        "created_at": "2014-04-28T11:19:28+00:00",
        "custom_domains": [{
            "hostname": "cdn.igniso.com",
            "ssl": "custom",
            "created_at": "2014-04-28T11:19:28+00:00"
        }]
    }]
}

Errors that are thrown will use this format:

{
    "errors": [{
        "code": 1002,
        "message": "Invalid alias"
    }]
}

Rate Limit

API calls are limited to 1000 in one hour. Details of the number of calls remaining, rate limit and the reset time are provided in the headers detailed below:

X-RateLimit-Limit →1000
X-RateLimit-Remaining →986
X-RateLimit-Reset →141268909

Get Resources

Get a list of all your resources.

GET https://cdnify.com/api/v1/resources

Get Resource

Get a single resource by its ID.

GET https://cdnify.com/api/v1/resources/{resource_id}

Create Resource

Create a new resource.

POST https://cdnify.com/api/v1/resources

Parameters

Name Type Required Description
alias string yes The resource alias, e.g. 'igniso'
origin string yes The origin, e.g. 'igniso.com'

Status codes

Code Description
200 The resource was created
400 Something went wrong
429 Rate limit reached

Example

Use the command line to create a resource by running:

$ curl -X POST -u "YOURAPIKEY:x" https://cdnify.com/api/v1/resources -F alias=yourresource -F origin=http://mysite.com

Change the following:

YOURAPIKEY: It's your API key which can be found in your dashboard account settings or at the top of this page when logged in.

yourresource: Whatever you want to call your resource.

http://mysite.com: Your site's domain name.

Update Resource

Update a resource by its ID.

PATCH https://cdnify.com/api/v1/resources/{resource_id}

Parameters

Name Type Required Description
alias string no The resource alias, e.g. 'igniso'
origin string no The origin, e.g. 'igniso.com'

Status codes

Code Description
200 The resource was updated
400 Something went wrong
429 Rate limit reached

Delete Resource

Delete a resource by its ID. Successful deletions will not have a response body.

DELETE https://cdnify.com/api/v1/resources/{resource_id}

Status Codes

Code Description
204 The resource was deleted
400 Something went wrong
429 Rate limit reached

Get Resource Bandwidth

Get resource bandwidth by dates.

GET https://cdnify.com/api/v1/stats/{resource_id}/bandwidth?datefrom={YYYY-MM-DD}&dateto={YYYY-MM-DD}

Parameters

Name Type Required Description
resource_id array yes Resource ID: 01a0101
datefrom array yes Bandwidth date from: YYYY-MM-DD
dateto array yes Bandwidth date to: YYYY-MM-DD

Status Codes

Code Description
400 datefrom should be in the format YYYY-MM-DD
400 dateto should be in the format YYYY-MM-DD
404 Failed to find resource
429 Rate limit reached

Get Overall Bandwidth

Get overall bandwidth by dates.

GET https://cdnify.com/api/v1/stats/bandwidth?datefrom={YYYY-MM-DD}&dateto={YYYY-MM-DD}

Parameters

Name Type Required Description
datefrom array yes Bandwidth date from: YYYY-MM-DD
dateto array yes Bandwidth date to: YYYY-MM-DD

Status Codes

Code Description
400 datefrom should be in the format YYYY-MM-DD
400 dateto should be in the format YYYY-MM-DD
429 Rate limit reached

Purge Cache

Purge the cache of a resource by its ID. Successful cache purges will not have a response body.

DELETE https://cdnify.com/api/v1/resources/{resource_id}/cache

Parameters

Name Type Required Description
files array no An array of filenames; e.g. ['/js/jquery.js']

If the files parameter is not specified, then all assets will be purged.

Status codes

Code Description
204 The cache was purged
400 Something went wrong
429 Rate limit reached

Error Codes

Code Description
1001 Did not get all required data to create the resource
1002 Alias invalid
1003 Origin invalid
1004 Alias already in use