CDN
Edge content distributions, cache purge (by path, tag or everything) and delivery stats across major CDN vendors.
Overview
https://api.infrai.cc/v1/cdnAuthorization: Bearer $INFRAI_API_KEY# Call any /v1/cdn capability over raw HTTP — no SDK to install.
# curl:
curl https://api.infrai.cc/v1/cdn/... \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json"Methods
cdn.distribution.create
Create a CDN distribution (a vendor zone/service/domain) that fronts an origin with an edge cache, returning the CNAME target to point your hostname at.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
origin | string | Required | Origin host/URL the edge fronts. |
domain | string | Optional | Public delivery hostname (CNAME target). |
enabled | boolean | Optional | Whether the distribution serves traffic. |
cache_ttl_seconds | number | Optional | Default edge cache TTL in seconds. |
allowed_methods | string[] | Optional | HTTP methods the edge forwards. |
https_only | boolean | Optional | Force HTTPS at the edge. |
tags | string[] | Optional | Cache-tag / surrogate-key labels. |
vendor | string | Optional | Optional explicit vendor pin; otherwise resolved by region. |
Returns
Distribution { distribution_id, origin, domain, enabled, status }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/cdn/distribution/create \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"origin": "..."}'import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/cdn/distribution/create",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'origin': '...'},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/cdn/distribution/create",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"origin": "..."}),
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/cdn/distribution/create",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"origin": "..."}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);cdn.distribution.get
Fetch a CDN distribution's current state, edge hostname, and origin configuration.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
distribution_id | string | Required | The distribution id. |
Returns
DistributionExample
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/cdn/distribution/get/DISTRIBUTION_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/cdn/distribution/get/DISTRIBUTION_ID",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/cdn/distribution/get/DISTRIBUTION_ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/cdn/distribution/get/DISTRIBUTION_ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);cdn.distribution.list
List all CDN distributions on the account.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
cursor | string | Optional | Opaque pagination cursor. |
limit | number | Optional | Maximum number of items to return. |
Returns
{ items: Distribution[], next_cursor?: string }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/cdn/distribution/list \
-H "Authorization: Bearer $INFRAI_API_KEY"import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/cdn/distribution/list",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/cdn/distribution/list",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/cdn/distribution/list",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);cdn.distribution.update
Update a CDN distribution (enable/disable, origin, cache settings).
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
distribution_id | string | Required | The distribution id. |
origin | string | Optional | Origin host/URL the edge fronts. |
domain | string | Optional | Public delivery hostname (CNAME target). |
enabled | boolean | Optional | Whether the distribution serves traffic. |
cache_ttl_seconds | number | Optional | Default edge cache TTL in seconds. |
allowed_methods | string[] | Optional | HTTP methods the edge forwards. |
https_only | boolean | Optional | Force HTTPS at the edge. |
tags | string[] | Optional | Cache-tag / surrogate-key labels. |
vendor | string | Optional | Optional explicit vendor pin; otherwise resolved by region. |
Returns
DistributionExample
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X PATCH https://api.infrai.cc/v1/cdn/distribution/update/DISTRIBUTION_ID \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"origin": "..."}'import os, requests
resp = requests.patch(
"https://api.infrai.cc/v1/cdn/distribution/update/DISTRIBUTION_ID",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'origin': '...'},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/cdn/distribution/update/DISTRIBUTION_ID",
{
method: "PATCH",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"origin": "..."}),
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/cdn/distribution/update/DISTRIBUTION_ID",
{
method: "PATCH",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"origin": "..."}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);cdn.distribution.delete
Delete a CDN distribution and tear down its edge configuration.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
distribution_id | string | Required | The distribution id. |
Returns
{ ok: boolean }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X DELETE https://api.infrai.cc/v1/cdn/distribution/delete/DISTRIBUTION_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"import os, requests
resp = requests.delete(
"https://api.infrai.cc/v1/cdn/distribution/delete/DISTRIBUTION_ID",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/cdn/distribution/delete/DISTRIBUTION_ID",
{
method: "DELETE",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/cdn/distribution/delete/DISTRIBUTION_ID",
{
method: "DELETE",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);cdn.cache.purge
Purge the CDN edge cache for a distribution — by path, by cache-tag/surrogate-key, or everything. Billable work-action.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
distribution_id | string | Required | The distribution id. |
paths | string[] | Optional | Specific URLs / path prefixes to purge. |
tags | string[] | Optional | Cache-tag / surrogate-key purge. |
purge_everything | boolean | Optional | Purge the entire cache. |
idempotency_key | string | Optional | Client-supplied key to make the call idempotent. |
vendor | string | Optional | Optional explicit vendor pin; otherwise resolved by region. |
Returns
{ ok: boolean, purge_id?: string }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/cdn/cache/purge \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"distribution_id": "..."}'import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/cdn/cache/purge",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'distribution_id': '...'},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/cdn/cache/purge",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"distribution_id": "..."}),
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/cdn/cache/purge",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"distribution_id": "..."}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);cdn.cache.stats
Read cache analytics for a distribution: requests, hit/miss, hit ratio, and bytes delivered (the metered egress that drives delivery billing).
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
distribution_id | string | Optional | The distribution id. |
from | string | Optional | Start of the stats time range. |
to | string | Optional | End of the stats time range. |
Returns
{ requests, bytes_served, hit_ratio }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/cdn/cache/stats \
-H "Authorization: Bearer $INFRAI_API_KEY"import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/cdn/cache/stats",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/cdn/cache/stats",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/cdn/cache/stats",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);Advanced: pin a vendor
By default infrai routes each call to the best available provider — you do not pick a vendor. As an escape hatch, this capability accepts an optional vendor parameter to pin one specific provider. Every live vendor for this capability is available in real time from the discovery endpoint for the capability id — see the discovery API.
GET /v1/discovery/{capability}cdn.distribution.create
cdn.distribution.update
cdn.cache.purge
All capabilities
Every routed capability in this module — the complete public REST contract. The methods above are the guided walkthrough; this index is the full reference.
| Capability | Endpoint | Description |
|---|---|---|
cdn.cache.purge | POST /v1/cdn/cache/purge | Purge the CDN edge cache for a distribution — by path, by cache-tag/surrogate-key, or everything. Billable work-action. |
cdn.cache.stats | GET /v1/cdn/cache/stats | Read cache analytics for a distribution: requests, hit/miss, hit ratio, and bytes delivered (the metered egress that drives delivery billing). |
cdn.distribution.create | POST /v1/cdn/distribution/create | Create a CDN distribution (a vendor zone/service/domain) that fronts an origin with an edge cache, returning the CNAME target to point your hostname at. |
cdn.distribution.delete | DELETE /v1/cdn/distribution/delete/{distribution_id} | Delete a CDN distribution and tear down its edge configuration. |
cdn.distribution.get | GET /v1/cdn/distribution/get/{distribution_id} | Fetch a CDN distribution's current state, edge hostname, and origin configuration. |
cdn.distribution.list | GET /v1/cdn/distribution/list | List all CDN distributions on the account. |
cdn.distribution.update | PATCH /v1/cdn/distribution/update/{distribution_id} | Update a CDN distribution (enable/disable, origin, cache settings). |
End-to-end example
A production-style walkthrough of this module: configure once, then run the flow. It exercises most of the module's APIs.
A copy-paste-runnable single-file Python program (stdlib only, no SDK): set your INFRAI_API_KEY, run it, and walk this module's core flow with REAL billed calls — later steps reuse real fields returned by earlier ones. The 12-line helper is the entire integration.
#!/usr/bin/env python3
"""Infrai · cdn — runnable real-app example (single file, zero deps).
Copy this file, set your key, run it: every step is a REAL call to
api.infrai.cc, billed at the real (tiny) per-call price, printing the
live JSON response. Get a key at https://console.infrai.cc (Google/
GitHub sign-in grants $2 free credit). No SDK — the 12-line helper
below is the entire integration."""
import json
import os
from urllib import error, request
KEY = os.environ.get("INFRAI_API_KEY") or "ifr_pk_proj_..." # <- your key
BASE = "https://api.infrai.cc"
# Same raw HTTPS POST/GET as every per-method example on this page —
# wrapped once for reuse. There is nothing else to it: no SDK.
def infrai(method, path, body=None):
req = request.Request(
BASE + path, method=method,
data=json.dumps(body).encode() if body is not None else None,
headers={"Authorization": f"Bearer {KEY}",
"Content-Type": "application/json"})
try:
with request.urlopen(req, timeout=60) as r:
return json.loads(r.read())
except error.HTTPError as e:
return json.loads(e.read())
def show(label, resp):
print(f"\n== {label} ==")
print(json.dumps(resp, indent=2, ensure_ascii=False))
return resp
# 1) cdn.distribution.create — POST /v1/cdn/distribution/create · Create a CDN distribution (a vendor zone/service/domain) that fronts an origin with an edge cache, returning the CNAME target to point your hostname at.
r1 = show("cdn.distribution.create", infrai("POST", "/v1/cdn/distribution/create", {"origin":"..."}))
# 2) cdn.cache.purge — POST /v1/cdn/cache/purge · Purge the CDN edge cache for a distribution — by path, by cache-tag/surrogate-key, or everything. Billable work-action.
r2 = show("cdn.cache.purge", infrai("POST", "/v1/cdn/cache/purge", {"distribution_id":"..."}))
# 3) cdn.distribution.list — GET /v1/cdn/distribution/list · List all CDN distributions on the account.
r3 = show("cdn.distribution.list", infrai("GET", "/v1/cdn/distribution/list"))
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."# 1) Auth: every call is a raw HTTPS request to the Infrai gateway carrying
# only your project key. No SDK, no install.
# Get your key: sign in with Google/GitHub at the console for a project key
# + $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..." # from the console
# 2) cdn.distribution.create
curl -X POST https://api.infrai.cc/v1/cdn/distribution/create \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"origin": "..."}'
# 3) cdn.distribution.get
curl -X GET https://api.infrai.cc/v1/cdn/distribution/get/DISTRIBUTION_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 4) cdn.distribution.list
curl -X GET https://api.infrai.cc/v1/cdn/distribution/list \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 5) cdn.distribution.update
curl -X PATCH https://api.infrai.cc/v1/cdn/distribution/update/DISTRIBUTION_ID \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"origin": "..."}'
# 6) cdn.distribution.delete
curl -X DELETE https://api.infrai.cc/v1/cdn/distribution/delete/DISTRIBUTION_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 7) cdn.cache.purge
curl -X POST https://api.infrai.cc/v1/cdn/cache/purge \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"distribution_id": "..."}'
# 8) cdn.cache.stats
curl -X GET https://api.infrai.cc/v1/cdn/cache/stats \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 1) Auth: every call is a raw HTTPS request carrying only your project key.
# No SDK to install — just the `requests` library.
import os, requests
BASE = "https://api.infrai.cc"
HEADERS = {
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
"Content-Type": "application/json",
}
# 2) cdn.distribution.create
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/cdn/distribution/create",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'origin': '...'},
)
resp.raise_for_status()
print(resp.json())
# 3) cdn.distribution.get
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/cdn/distribution/get/DISTRIBUTION_ID",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())
# 4) cdn.distribution.list
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/cdn/distribution/list",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())
# 5) cdn.distribution.update
import os, requests
resp = requests.patch(
"https://api.infrai.cc/v1/cdn/distribution/update/DISTRIBUTION_ID",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'origin': '...'},
)
resp.raise_for_status()
print(resp.json())
# 6) cdn.distribution.delete
import os, requests
resp = requests.delete(
"https://api.infrai.cc/v1/cdn/distribution/delete/DISTRIBUTION_ID",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())
# 7) cdn.cache.purge
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/cdn/cache/purge",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'distribution_id': '...'},
)
resp.raise_for_status()
print(resp.json())
# 8) cdn.cache.stats
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/cdn/cache/stats",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())
// 1) Auth: every call is a raw HTTPS request carrying only your project key.
// No SDK to install — just the built-in fetch().
const BASE = "https://api.infrai.cc";
const HEADERS = {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
};
// 2) cdn.distribution.create
const resp = await fetch(
"https://api.infrai.cc/v1/cdn/distribution/create",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"origin": "..."}),
},
);
console.log(await resp.json());
// 3) cdn.distribution.get
const resp = await fetch(
"https://api.infrai.cc/v1/cdn/distribution/get/DISTRIBUTION_ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());
// 4) cdn.distribution.list
const resp = await fetch(
"https://api.infrai.cc/v1/cdn/distribution/list",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());
// 5) cdn.distribution.update
const resp = await fetch(
"https://api.infrai.cc/v1/cdn/distribution/update/DISTRIBUTION_ID",
{
method: "PATCH",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"origin": "..."}),
},
);
console.log(await resp.json());
// 6) cdn.distribution.delete
const resp = await fetch(
"https://api.infrai.cc/v1/cdn/distribution/delete/DISTRIBUTION_ID",
{
method: "DELETE",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());
// 7) cdn.cache.purge
const resp = await fetch(
"https://api.infrai.cc/v1/cdn/cache/purge",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"distribution_id": "..."}),
},
);
console.log(await resp.json());
// 8) cdn.cache.stats
const resp = await fetch(
"https://api.infrai.cc/v1/cdn/cache/stats",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());
// 1) Auth: every call is a raw HTTPS request carrying only your project key.
// No SDK to install — just the built-in fetch(), typed.
const BASE = "https://api.infrai.cc";
const HEADERS: Record<string, string> = {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
};
// 2) cdn.distribution.create
const resp = await fetch(
"https://api.infrai.cc/v1/cdn/distribution/create",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"origin": "..."}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 3) cdn.distribution.get
const resp = await fetch(
"https://api.infrai.cc/v1/cdn/distribution/get/DISTRIBUTION_ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 4) cdn.distribution.list
const resp = await fetch(
"https://api.infrai.cc/v1/cdn/distribution/list",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 5) cdn.distribution.update
const resp = await fetch(
"https://api.infrai.cc/v1/cdn/distribution/update/DISTRIBUTION_ID",
{
method: "PATCH",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"origin": "..."}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 6) cdn.distribution.delete
const resp = await fetch(
"https://api.infrai.cc/v1/cdn/distribution/delete/DISTRIBUTION_ID",
{
method: "DELETE",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 7) cdn.cache.purge
const resp = await fetch(
"https://api.infrai.cc/v1/cdn/cache/purge",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"distribution_id": "..."}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 8) cdn.cache.stats
const resp = await fetch(
"https://api.infrai.cc/v1/cdn/cache/stats",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);