API documentation - 1 -
Table of Contents 1. Introduction 1.1. What is an API 2. API Functions 2.1. Purge list of files 2.1.1 Description 2.1.2 Implementation 2.2. Purge of whole cache (all files on all edge servers) 2.2.1 Description 2.2.2 Implementation 2.3. Prefetch file to edge servers local cache 2.3.1 Description 2.3.2 Implementation 2.4. Create CDN resource 2.4.1 Description 2.4.2 Implementation 2.5. Delete CDN resource 2.5.1 Description 2.5.2 Implementation 2.6. Edit CDN resource 2.6.1 Description 2.6.2 Implementation 2.7. Fetch statistics data 2.7.1 Description 2.7.2 Implementation 2.8. Get CDN details 2.8.1 Description 2.8.2 Implementation - 2 -
1. Introduction 1.1. What is an API API is application programming interface and it allows to communicate with CDN77 service through JSON (JavaScript Object Notation). CDN77 API allows you to do various commands and tasks, like creating new CDN resource, editation of CDN resource, purging edge servers local cache and other tasks needed when using CDN77 from external script or server. 1.2. Supported API functions Supported CDN77 s API functions are: Purge of whole edge servers local cache Purge list of file(s) Prefetch content to edge servers local cache CDN resource editation creation details removal Traffic statistics - 3 -
2. API Functions 2.1. Purge list of files 2.1.1 Description Purge API request is used in case, the invalidation of some files in edge servers local cache is needed. (for instance: when refresh of files in the CDN to new version is needed). It takes from 2 to 10 minutes, until the request for file removal is processed. 2.1.2 Implementation Following HTTP POST parameters is accepted on the following gateway: https://client.cdn77.com/api/purge POST parameter name Parameter description Example of usage id login ID of CDN resource, on which the content will be purged Login to CDN77 client section 1234 sample@account.com passwd API password 8vL4BpXbRqgPTKA0hV36dWjMTNfIk ZK8 json Contains paths of files to be purged Single file: {"purge_paths":"path/to/your/file.jpg"} More files: {"purge_paths":"/path/to/file1.png\n/path/ to/file2.png\n/path/to/otherfile.png"} All parameters are required. Additional notes: - 4 -
id of CDN resource can be found in the CDN list: https://client.cdn77.com/cdn/list API password can be found in the API section, which can be found in the client section: https://client.cdn77.com/cdn/how-to-purge Limitations of purge API method allowed requests per second: 1 allowed requests per day: 1000 Example of usage (via Linux s curl utility): Purging of single file: curl --data "id=id of cdn&login=sample@account.com&passwd=your api password&json={'purge_paths':'/path/to/file.jpg'}" https:// client.cdn77.com/api/purge Purging of more files at once: curl --data "id=id of cdn&login=sample@account.com&passwd=your api password&json={'purge_paths':'/path/to/file.jpg\n/path/to/ file2.jpg\n/path/to/file3.jpg''}" https://client.cdn77.com/api/purge It returns status : ok JSON response in success and any other response or status is failure. Example of successful purge API response: {"status":"ok","description":"purge request successful"} string(19) "{'purge_paths':'/'}" - 5 -
2.2. Purge of whole cache (all files on all edge servers) 2.2.1 Description Purge of whole cache API request is used in case, the invalidation of all files in edge servers local cache is needed. (for instance: when refresh of all files in the CDN to new version is needed). It takes from 2 to 10 minutes, until the request for file removal is processed. 2.2.2 Implementation Following HTTP POST parameters is accepted on the following gateway: https://client.cdn77.com/api/purge-all POST parameter name Parameter description Example of usage id login ID of CDN resource, on which the content will be purged Login to CDN77 client section 1234 sample@account.com passwd API password 8vL4BpXbRqgPTKA0hV36dWjMTNfIkZK8 All parameters are required. - 6 -
Additional notes: id of CDN resource can be found in the CDN list: https://client.cdn77.com/cdn/list API password can be found in the API section, which can be found in the client section: https://client.cdn77.com/cdn/how-to-purge-all Limitations of purge all API method allowed requests per second: 1 allowed requests per day: 1000 Example of usage (via Linux s curl utility): curl --data "id=id of cdn&login=sample@account.com&passwd=your api password" https://client.cdn77.com/api/purge-all It returns status : ok JSON response in success and any other response or status is failure. Example of successful purge all API response: {"status":"ok","description":"purge request successful"} - 7 -
2.3. Prefetch file to edge servers local cache 2.3.1 Description Prefetch of desired file or files to edge servers local cache is used in case, the predownload of all desired files from origin to edge servers cache is needed. (for instance: when new files are uploaded and it is needed to upload them to edge servers local cache before presenting them to public). There is one advantage of doing this: The CDN cache can be pre-filled, so it will be present there, when presented to public. This practically means, that even the first request from visitor to this new file, will be served from edge servers local cache and so it will be faster, than in case the file is not in the edge servers local cache yet and has to be downloaded from origin at first. It takes from 2 to 10 minutes, until the request for file removal is processed. The whole time of upload to edge servers depends on the connectivity (bandwidth) between the origin and edge server (and on the load on the line of course; in example: it will be faster if there is 1 Gbps network on the origin and on the edge server than in case of 100 Mbps on origin or edge server). 2.3.2 Implementation Following HTTP POST parameters is accepted on the following gateway: https://client.cdn77.com/api/prefetch POST parameter name Parameter description Example of usage - 8 -
id login ID of CDN resource, on which the content will be purged Login to CDN77 client section 1234 sample@account.com passwd API password 8vL4BpXbRqgPTKA0hV36dWjMTNfIkZK8 json Contains paths of files to be purged Single file: {"prefetch_paths":"path/to/your/file.jpg"} More files: {"prefetch_paths":"/path/to/file1.png\n/path/to/file2.png\n/path/to/ otherfile.png"} All parameters are required. Additional notes: id of CDN resource can be found in the CDN list: https://client.cdn77.com/cdn/list API password can be found in the API section, which can be found in the client section: https://client.cdn77.com/cdn/how-to-prefetch Limitations of prefetch API method allowed requests per second: 1 allowed requests per day: 1000 Example of usage (via Linux s curl utility): Prefetching of single file: curl --data "id=id of cdn&login=sample@account.com&passwd=your api password&json={'prefetch_paths':'/path/to/file.jpg'}" https:// client.cdn77.com/api/prefetch Prefetching of more files at once: - 9 -
curl --data "id=id of cdn&login=sample@account.com&passwd=your api password&json={'prefetch_paths':'/path/to/file.jpg\n/path/to/ file2.jpg\n/path/to/file3.jpg''}" https://client.cdn77.com/api/prefetch It returns status : ok JSON response in success and any other response or status is failure. Example of successful prefetch API response: {"status":"ok","description":"prefetch request successful"} 2.4. Create CDN resource 2.4.1 Description New CDN resource can be created via API just like from the client section. Origin domain, cname and SSL support can be chosen in the creation. 2.4.2 Implementation Following HTTP POST parameters is accepted on the following gateway: https://client.cdn77.com/api/create-cdn POST parameter name Parameter description Example of usage origin_url cname Origin domain, from which the content will be pulled CNAME for your CDN resource www.yourwebsite.com (without protocol specification) cdn.yourwebsite.com (without protocol specification) - 10 -
ssl Type of CDN resource values: 0 = SSL disabled (custom CNAME could be used) 1 = SSL enabled (CNAME must end with r.worldssl.net ) method login Amount of data returned in response Login to CDN77 client section values: verbose = more data will be returned in response without value (not present/not set or null) = simple response without CDN resource ID etc. sample@account.com passwd API password 8vL4BpXbRqgPTKA0hV36dWjMTNfIkZK8 All parameters are required, except for method parameter, which is optional. Additional notes: id of CDN resource can be found in the CDN list: https://client.cdn77.com/cdn/list API password can be found in the API section, which can be found in the client section: https://client.cdn77.com/cdn/how-to-create Limitations of prefetch API method allowed requests per second: 1 allowed requests per day: 100 Example of usage (via Linux s curl utility): Creating CDN resource without SSL support: curl --data "login=sample@account.com&passwd=your api password&origin_url=www.yourwebsite.com&cname=cdn.yourwebsite.com&ssl=0" https://client.cdn77.com/api/create-cdn It returns status : ok JSON response in success and any other response or status is failure. - 11 -
Example of successful create CDN API response: {"status":"ok","description":"cdn cdn.yourwebsite.com created"} Creating CDN resource without SSL support with method present and with value verbose : curl --data "login=sample@account.com&passwd=your api password&origin_url=www.yourwebsite.com&cname=cdn.yourwebsite.com&ssl=0&method=verbose" https://client.cdn77.com/api/createcdn It returns status : ok JSON response in success and any other response or status ( status : error ) is failure. Example of successful create CDN API response: {"status":"ok","description":"cdn cdn.yourwebsite.com created","id":1234,"cdnurl":"733812352.r.cdn77.net","cname":"cdn.yourwebsite.com"} 2.5. Delete CDN resource 2.5.1 Description Any CDN resource can be deleted via API (via its ID) just like from the client section. 2.5.2 Implementation Following HTTP POST parameters is accepted on the following gateway: https://client.cdn77.com/api/delete-cdn POST parameter name Parameter description Example of usage - 12 -
id login ID of CDN resource, on which the Login to CDN77 client section 1234 sample@account.com passwd API password 8vL4BpXbRqgPTKA0hV36dWjMTNfIkZK8 All parameters are required. Additional notes: id of CDN resource can be found in the CDN list: https://client.cdn77.com/cdn/list API password can be found in the API section, which can be found in the client section: https://client.cdn77.com/cdn/how-to-delete Limitations of prefetch API method allowed requests per second: 1 allowed requests per day: 100 Example of usage (via Linux s curl utility): Deleting CDN resource with ID 1234: curl --data "id=1234&login=sample@account.com&passwd=your api password" https://client.cdn77.com/api/delete-cdn It returns status : ok JSON response in success and any other response or status is failure. Example of successful delete CDN API response: {"status":"ok","description":"cdn id 1234 was deleted"} - 13 -
2.6. Edit CDN resource 2.6.1 Description Any CDN resource can be edited via API (via its ID). Not all settings from client section are available via API. 2.6.2 Implementation Following HTTP POST parameters is accepted on the following gateway: https://client.cdn77.com/api/edit-cdn POST parameter name Parameter description Example of usage id login ID of CDN resource, on which the Login to CDN77 client section 1234 sample@account.com passwd API password 8vL4BpXbRqgPTKA0hV36dWjMTNfIkZK8 origin_url cname Origin URL from which the content will be pulled (source of files for CDN) CNAME for your CDN resource www.yourdomain.com cdn.yourdomain.com cache_expiry Cache Expiry value (cache TTL) 14400 (see additional notes below this table, to see all allowed values) - 14 -
url_signing_on Switch token authentication setting values: 1 = url signing enabled 0 = url signing disabled url_signing_key Set token authentication key (password) rkybztaapfhsv5nd (it must be 16 characters long) All parameters are optional, except for id, login and password, which are required. Additional notes: id of CDN resource can be found in the CDN list: https://client.cdn77.com/cdn/list API password can be found in the API section, which can be found in the client section: https://client.cdn77.com/cdn/how-to-edit-cdn Limitations of prefetch API method allowed requests per second: 1 allowed requests per day: 1000 allowed cache_expiry values: 10, 30, 60, 240, 720, 1440, 2880, 4320, 5760, 7200, 8640, 10080, 11520, 12960, 14400, 15840, 17280 cache_expiry values are in minutes cache_expiry value can be overridden by setting custom Expires and Cache-Control headers on the origin url_signing_key must be equal 16 characters Example of usage (via Linux s curl utility): Editing CDN resource with ID 1234: curl --data "login=sample@account.com&passwd=your api password&id=1234&origin_url=www.yourwebsite.com&cname=cdn.yourwebsite.com&cache_expiry=14400&url_signing_on=1&url_signing _key=abcdefghij123456" https://client.cdn77.com/api/edit-cdn - 15 -
It returns status : ok JSON response in success and any other response or status is failure. Example of successful edit CDN API response: {"status":"ok","description":"cdn id 1234 updated;origin_url updated to www.yourwebsite.com;cname updated to cdn.yourwebsite.com;cache_expiry updated to 14400;url_signing_key updated to abcdefghij123456;url_signing_on updated to 1"} 2.7. Fetch statistics data 2.7.1 Description purposes. Traffic statistics data can be fetched via API for any further processing or archiving 2.7.2 Implementation Following HTTP POST parameters is accepted on the following gateway: https://client.cdn77.com/api/traffic POST parameter name Parameter description Example of usage id login ID of CDN resource, on which the Login to CDN77 client section 1234 sample@account.com passwd API password 8vL4BpXbRqgPTKA0hV36dWjMTNfIkZK8-16 -
All parameters are required. Additional notes: id of CDN resource can be found in the CDN list: https://client.cdn77.com/cdn/list if id parameter set to all then traffic statistics for all CDN resources will be returned API password can be found in the API section, which can be found in the client section: https://client.cdn77.com/cdn/how-to-traffic Limitations of prefetch API method allowed requests per second: 1 allowed requests per day: 1000 Example of usage (via Linux s curl utility): Getting traffic statistics for CDN resource with ID 1234: curl --data "id=1234&login=sample@account.com&passwd=your api password" https://client.cdn77.com/api/traffic It returns status : ok JSON response in success and any other response or status is failure. Example of successful CDN traffic statistics API response: {"24h":"164.95 MB","48h":"399.47 MB","30d":"14.67 GB","02m":"0 Bytes","01m":"35.56 GB","00m":"14.67 GB"} - 17 -
Getting traffic statistics for all CDN resources: curl --data "id=all&login=sample@account.com&passwd=your api password" https://client.cdn77.com/api/traffic It returns status : ok JSON response in success and any other response or status is failure. Example of successful CDN traffic statistics API response: {"24h":"164.95 MB","48h":"399.56 MB","30d":"36.61 GB","02m":"206.82 KB","01m":"115.58 GB","00m":"29.05 GB"} 2.8. Get CDN details 2.8.1 Description Get details (of settings) of CDN resource. 2.8.2 Implementation Following HTTP POST parameters is accepted on the following gateway: https://client.cdn77.com/api/cdn-detail POST parameter name Parameter description Example of usage id login ID of CDN resource, on which the Login to CDN77 client section 1234 sample@account.com passwd API password 8vL4BpXbRqgPTKA0hV36dWjMTNfIkZK8-18 -
All parameters are required, except for id parameter. - 19 -
Additional notes: id of CDN resource can be found in the CDN list: https://client.cdn77.com/cdn/list if id parameter is missing, details for all CDN resources will be shown (this could take a while) API password can be found in the API section, which can be found in the client section: https://client.cdn77.com/cdn/how-to-cdn-detail Limitations of prefetch API method allowed requests per second: 1 allowed requests per day: 1000 Getting details of settings for CDN resource with ID 1234: curl --data "id=1234&login=sample@account.com&passwd=your api password" https://client.cdn77.com/api/cdn-detail It returns status : ok JSON response in success and any other response or status is failure. Example of successful CDN traffic statistics API response: {"status":"ok","description":[{"id":1234,"origin_url":"www.yourwebsite.com","cname":"cdn.yourwebsite.com","cdn_url":"105264313.r.cdn78.n et","cache_expiry":2880,"url_signing_on":false,"url_signing_key":""}]} Getting details of settings for all CDN resources: curl --data "login=sample@account.com&passwd=your api password" https://client.cdn77.com/api/cdn-detail - 20 -
It returns status : ok JSON response in success and any other response or status is failure. Example of successful CDN traffic statistics API response: {"status":"ok","description":[{"id":4004,"origin_url":"www.yourwebsite.com","cname":"cdn.yourwebsite.com", "cdn_url":"123499422.r.cdn77.net","cache_expiry":14400,"url_signing_on":true,"url_signing_key":"abcd5mn6ipzpjmxd"}, {"id":3308,"origin_url":"www.yourwebsite2.com","cname":"cdn.yourwebsite2.com","cdn_url":"361236165.r.cdn77.net", "cache_expiry":2160,"url_signing_on":false,"url_signing_key":""}]} - 21 -