CDN¶
Create an API Key and access token:-¶
For create a API Key and Access Token to refer this link :-
https://www.e2enetworks.com/help/knowledge-base/how-to-create-an-api-access-token/
List of CDN¶
To find the list of CDN, send a HTTP GET request :-
https://api.e2enetworks.com/myaccount/api/v1/cdn/distributions/?apikey={{apikey}}&&page_no=1&per_page=5
PYTHON¶
1. Python - http.client Example
import http.client
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = ''
headers = {
'Authorization': 'API_token ',
}
conn.request("GET", "/myaccount/api/v1/cdn/distributions/?apikey={{api_key}}&null=null&page_no=1&per_page=5", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
2. Python - Requests Example
import requests
url = "https://api.e2enetworks.com/myaccount/api/v1/cdn/distributions/?apikey={{api_key}}&&page_no=1&per_page=5"
payload={}
headers = {
'Authorization': 'api_token ',
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
Headers¶
Request Headers¶
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
Response Headers:-¶
content-type: application/json; charset=utf-8
status: 202 Accepted
Body¶
Response Body¶
{
"code": 200,
"data": [
{
"id": 555,
"domain_id": "E25M1DQYKR0WO9",
"user_domain_name": "angular.com",
"e2e_domain_name": "angularlqgv41u3qd.cdn.e2enetworks.net",
"domain_state": "Deployed",
"is_enabled": false,
"created_at": "06/Jun/2022 06:45 PM"
}
],
"errors": {},
"message": "Success",
"total_page_number": 1,
"total_count": 1
}
Create a new CDN-¶
To create a CDN , send a Post request :-
https://api.e2enetworks.com/myaccount/api/v1/cdn/distributions/?apikey={{apikey}}
PYTHON¶
1. Python - http.client Example
import http.client
import json
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
"cache_details": {
"allowed_http_methods": "GET|HEAD",
"default_ttl": 86400,
"max_ttl": 3153000,
"min_ttl": 0,
"viewer_protocol_policy": "https-only"
},
"domain_details": {
"http_versions": "http2",
"is_ipv6_supported": False,
"root_object": ""
},
"domain_name": "shubha.com",
"origin_details": {
"keepalive_timeout": 5,
"origin_id": "shubha.com",
"origin_path": "/path",
"protocol_policy": "https-only",
"response_timeout": 30,
"ssl_protocol": "TLSv1.2"
}
})
headers = {
'Authorization': 'api_token',
'Content-Type': 'application/json',
}
conn.request("POST", "/myaccount/api/v1/cdn/distributions/?apikey={{api_key}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
2. Python - Requests Example
import requests
import json
url = "https://api.e2enetworks.com/myaccount/api/v1/cdn/distributions/?apikey={{api_key}}"
payload = json.dumps({
"cache_details": {
"allowed_http_methods": "GET|HEAD",
"default_ttl": 86400,
"max_ttl": 3153000,
"min_ttl": 0,
"viewer_protocol_policy": "https-only"
},
"domain_details": {
"http_versions": "http2",
"is_ipv6_supported": False,
"root_object": ""
},
"domain_name": "shubha.com",
"origin_details": {
"keepalive_timeout": 5,
"origin_id": "shubha.com",
"origin_path": "/path",
"protocol_policy": "https-only",
"response_timeout": 30,
"ssl_protocol": "TLSv1.2"
}
})
headers = {
'Authorization': 'api_token ',
'Content-Type': 'application/json',
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Headers¶
Request Headers¶
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
Response Headers:-¶
content-type: application/json; charset=utf-8
status: 202 Accepted
Body¶
Request Body¶
{
"cache_details": {
"allowed_http_methods": "GET|HEAD",
"default_ttl": 86400,
"max_ttl": 3153000,
"min_ttl": 0,
"viewer_protocol_policy": "https-only"
},
"domain_details": {
"http_versions": "http2",
"is_ipv6_supported": false,
"root_object": ""
},
"domain_name": "shubha.com",
"origin_details": {
"keepalive_timeout": 5,
"origin_id": "shubha.com",
"origin_path": "/shubh",
"protocol_policy": "https-only",
"response_timeout": 30,
"ssl_protocol": "TLSv1.2"
}
}
Response Body¶
{
"code": 200,
"data": {
"message": "Your Distribution has been created successfully. It will take upto 30 minutes to deploy. Please wait.",
"domain_id": "E2LEV9ATODOA3U",
"response_domain": "shubha58v6ggw1rn.cdn.e2enetworks.net"
},
"errors": {},
"message": "Success"
}
Delete a CDN -¶
To delete a CDN , send a DELETE request:-
https://api.e2enetworks.com/myaccount/api/v1/cdn/distributions/?apikey={{apikey}}&domain_id={{domain_id}}
PYTHON¶
1. Python - http.client Example
import http.client
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = ''
headers = {
'Authorization': 'api_token ',
}
conn.request("DELETE", "/myaccount/api/v1/cdn/distributions/?apikey={{api_key}}&domain_id={{domain_id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
2. Python - Requests Example
import requests
url = "https://api.e2enetworks.com/myaccount/api/v1/cdn/distributions/?apikey={{api_key}}&domain_id={{domain_id}}"
payload={}
headers = {
'Authorization': 'api_token',
}
response = requests.request("DELETE", url, headers=headers, data=payload)
print(response.text)
Headers¶
Request Headers¶
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
Response Headers:-¶
content-type: application/json; charset=utf-8
status: 202 Accepted
Body¶
Response Body¶
{
"code": 200,
"data": {
"message": "Your Distribution has been deleted successfully. "
},
"errors": {},
"message": "Success"
}
Enable CDN Distribution¶
To enable CDN Distribution , send a PUT request :-
https://api.e2enetworks.com/myaccount/api/v1/cdn/distributions/?apikey={{apikey}}
PYTHON¶
1. Python - http.client Example
import http.client
import json
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
"domain_id": "E2LEV9ATODOA3U",
"is_enabled": True
})
headers = {
'Authorization': 'api_token',
'Content-Type': 'application/json',
}
conn.request("PUT", "/myaccount/api/v1/cdn/distributions/?apikey={{api_key}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
2. Python - Requests Example
import requests
import json
url = "https://api.e2enetworks.com/myaccount/api/v1/cdn/distributions/?apikey={{api_key}}"
payload = json.dumps({
"domain_id": "E2LEV9ATODOA3U",
"is_enabled": True
})
headers = {
'Authorization': 'api_token ',
'Content-Type': 'application/json',
}
response = requests.request("PUT", url, headers=headers, data=payload)
print(response.text)
Headers¶
Request Headers¶
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
Response Headers:-¶
content-type: application/json; charset=utf-8
status: 202 Accepted
Body¶
Request Body-¶
{
"domain_id": "E2LEV9ATODOA3U",
"is_enabled": true
}
Response Body¶
{
"code": 200,
"data": {
"message": "Your Distribution has been updated successfully. It will take upto 30 minutes to deploy the new changes. Please wait."
},
"errors": {},
"message": "Success"
}
Disable CDN Distribution¶
To Disable CDN Distribution , send a PUT request-
https://api.e2enetworks.com/myaccount/api/v1/cdn/distributions/?apikey={{apikey}}
PYTHON¶
1. Python - http.client Example
import http.client
import json
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
"domain_id": "E2LEV9ATODOA3U",
"is_enabled": False
})
headers = {
'Authorization': 'Bearer ',
'Content-Type': 'application/json',
}
conn.request("PUT", "/myaccount/api/v1/cdn/distributions/?apikey={{api_key}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
2. Python - Requests Example
import requests
import json
url = "https://api.e2enetworks.com/myaccount/api/v1/cdn/distributions/?apikey={{api_key}}"
payload = json.dumps({
"domain_id": "E2LEV9ATODOA3U",
"is_enabled": False
})
headers = {
'Authorization': 'api_token',
'Content-Type': 'application/json',
}
response = requests.request("PUT", url, headers=headers, data=payload)
print(response.text)
Headers¶
Request Headers¶
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
Response Headers:-¶
content-type: application/json; charset=utf-8
status: 202 Accepted
Body¶
Request Body-¶
{
"domain_id": "E2LEV9ATODOA3U",
"is_enabled": false
}
Response Body¶
{
"code": 200,
"data": {
"message": "Your Distribution has been updated successfully. It will take upto 30 minutes to deploy the new changes. Please wait."
},
"errors": {},
"message": "Success"
}
CDN Monitoring¶
To view CDN Monitoring data to send a GET request-
https://api.e2enetworks.com/myaccount/api/v1/cdn/monitoring-data/?apikey={{apikey}}&location={{location}}&start_date={{start_date}}&end_date={{end_date}}&distribution_id={{distribution_id}}&granularity={{granularity}}}
PYTHON¶
1. Python - http.client Example
import http.client
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = ''
headers = {
'Authorization': 'Bearer '
}
conn.request("GET", "/myaccount/api/v1/cdn/monitoring-data/?apikey={{api_key}}&location=Delhi&start_date=2022-05-04&end_date=2022-05-19&distribution_id={{distribution_id}}&granularity=daily", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
2. Python - Requests Example
import requests
url = "https://api.e2enetworks.com/myaccount/api/v1/cdn/monitoring-data/?apikey={{api_key}}&location=Delhi&start_date=2022-05-04&end_date=2022-05-19&distribution_id={{distribution_id}}&granularity=daily"
payload={}
headers = {
'Authorization': 'api_token',
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
Headers¶
Request Headers¶
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
Response Headers:-¶
content-type: application/json; charset=utf-8
status: 202 Accepted
Body¶
Response Body¶
{
"code": 200,
"data": [],
"errors": {},
"message": "Success"
}
CDN Bandwidth Usages¶
To View CDN Bandwidth Usage, send a Post request :-
https://api.e2enetworks.com/myaccount/api/v1/cdn/domain-usage/?apikey={{apikey}}
PYTHON¶
1. Python - http.client Example
import http.client
import json
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
"domain": "all",
"end_date": "2022-05-19",
"granularity": "daily",
"start_date": "2022-05-04"
})
headers = {
'Authorization': 'api_token',
'Content-Type': 'application/json',
}
conn.request("POST", "/myaccount/api/v1/cdn/domain-usage/?apikey={{api_key}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
2. Python - Requests Example
import requests
import json
url = "https://api.e2enetworks.com/myaccount/api/v1/cdn/domain-usage/?apikey=7386660e-768b-4528-8528-02be604de4da"
payload = json.dumps({
"domain": "all",
"end_date": "2022-05-19",
"granularity": "daily",
"start_date": "2022-05-04"
})
headers = {
'Authorization': 'api_token',
'Content-Type': 'application/json',
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Headers¶
Request Headers¶
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
Response Headers:-¶
content-type: application/json; charset=utf-8
status: 202 Accepted
Body¶
Request Body-¶
{
"domain": "all",
"end_date": "2022-05-19",
"granularity": "daily",
"start_date": "2022-05-04"
}
Response Body¶
{
"code": 200,
"data": [],
"errors": {},
"message": "Success"
}