• No results found

API documentation - 1 -

N/A
N/A
Protected

Academic year: 2021

Share "API documentation - 1 -"

Copied!
21
0
0

Loading.... (view fulltext now)

Full text

(1)

API documentation

(2)

-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

(3)

-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 cachePurge list of file(s)

Prefetch content to edge servers’ local cache ● CDN resource

○ editation ○ creation ○ details ○ removal ● Traffic statistics

(4)

-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 ID of CDN resource, on

which the content will be purged

1234

login Login to CDN77 client

section

[email protected]

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:

(5)

-● 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&[email protected]&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&[email protected]&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':'/'}"

(6)

-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 ID of CDN

resource, on which the content will be purged

1234

login Login to

CDN77 client section

[email protected]

passwd API password 8vL4BpXbRqgPTKA0hV36dWjMTNfIkZK8 All parameters are required.

(7)

-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&[email protected]&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"}

(8)

-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 pre-download 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

(9)

-id ID of CDN resource, on which the content will be purged

1234

login Login to CDN77 client section

[email protected]

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&[email protected]&passwd=your api password&json={'prefetch_paths':'/path/to/file.jpg'}" https:// client.cdn77.com/api/prefetch

Prefetching of more files at once:

(10)

-curl --data "id=ID of cdn&[email protected]&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 Origin domain, from which the content will be pulled

www.yourwebsite.com (without protocol specification)

cname CNAME for your CDN resource

cdn.yourwebsite.com (without protocol specification)

(11)

-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 Amount of data returned in response

values:

● verbose = more data will be returned in response ● without value (not present/not set or null) = simple

response without CDN resource ID etc. login Login to CDN77

client section

[email protected]

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 "[email protected]&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.

(12)

-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 "[email protected]&passwd=your api

password&origin_url=www.yourwebsite.com&cname=cdn.yourwebsite.com&ssl=0&method=verbose" https: //client.cdn77.com/api/create-cdn

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

(13)

-id ID of CDN resource, on which the

1234

login Login to CDN77 client section

[email protected]

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&[email protected]&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"}

(14)

-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 ID of CDN

resource, on which the

1234

login Login to CDN77

client section

[email protected]

passwd API password 8vL4BpXbRqgPTKA0hV36dWjMTNfIkZK8 origin_url Origin URL from

which the content will be pulled (source of files for CDN)

www.yourdomain.com

cname CNAME for your

CDN resource

cdn.yourdomain.com

cache_expiry Cache Expiry value (cache TTL)

14400 (see additional notes below this table, to see all allowed values)

(15)

-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 "[email protected]&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

(16)

-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

Traffic statistics data can be fetched via API for any further processing or archiving purposes.

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 ID of CDN

resource, on which the

1234

login Login to CDN77

client section

[email protected]

passwd API password 8vL4BpXbRqgPTKA0hV36dWjMTNfIkZK8

(17)

-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&[email protected]&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"}

(18)

-Getting traffic statistics for all CDN resources:

curl --data "id=all&[email protected]&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 ID of CDN

resource, on which the

1234

login Login to CDN77

client section

[email protected]

passwd API password 8vL4BpXbRqgPTKA0hV36dWjMTNfIkZK8

(19)

-All parameters are required, except for “id” parameter.

(20)

-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&[email protected]&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 "[email protected]&passwd=your api password" https://client.cdn77.com/api/cdn-detail

(21)

-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":""}]}

References

Related documents

Selection Criteria for the Hyperbilirubinemic Group Characteristics of the neonatal period: (1) Birth weight ≥ 2500 g; gestational age >37 weeks; (2) Direct Coombs test

Percentage of the landscape in a particular habitat class was the most important characteristic predicting occupancy of most of our study species. The probability of occupancy for

In a technical report ( Doss and Narasimhan 1994 ), we introduced a computing environment within which one can interactively change the prior ν and immediately see the

Study cohort selection and division into subgroups We reviewed the center’s case database and identified patients diagnosed with DTC and referred for follow-up between January 1,

OBJECTIVE: The present study was designed to evaluate patients with differentiated thyroid carcinoma diagnosed before 20 years of age and to determine the factors associated with

in Care Industry Management Master’s degree in Business Administration Master’s degree in Human Resources Management Preparation for UE (Education Unit) 1 and 4 of the

The housing market is a market where there is asymmetric information. Generally speaking, suppliers have more information about the market than consumers..

In the() matching, we use the relative() values of corres p on '・ lines. In the ρmatching, we compute parameters of transfer and deviations ofρvalues. Finally, in the p,