PageCDN API
Cloud Storage & File SharingIntroduction to PageCDN API
PageCDN is a content delivery network that allows developers to easily optimize website performance. In order to interact with PageCDN, we provide a public API. In this document, we'll cover the basics of the PageCDN API.
Getting Started
To use the PageCDN API, you'll need to create an account on our website. Once you have an account, you can generate your API key. This key will be used to authenticate your requests to the API.
API Methods
CDN
Purge
Purge all CDN cache for the specified zone
fetch('https://api.pagecdn.io/v1/cdn/purge', {
method: 'POST',
body: JSON.stringify({
zone: "{{zone}}",
type: "both"
}),
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${YOUR_API_KEY}`
}
}).then(resp => console.log(resp))
.catch(err => console.error(err));
Images
Optimize
Optimize the given image URL.
fetch('https://api.pagecdn.io/v1/images/optimize', {
method: 'POST',
body: JSON.stringify({
url: '{{url}}',
compressionType: 'lossless'
}),
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${YOUR_API_KEY}`
}
}).then(resp => console.log(resp))
.catch(err => console.error(err));
Resize
Resize the given image URL with the given width and height.
fetch('https://api.pagecdn.io/v1/images/resize', {
method: 'POST',
body: JSON.stringify({
url: '{{url}}',
width: 300,
height: 300,
compressionType: 'lossless'
}),
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${YOUR_API_KEY}`
}
}).then(resp => console.log(resp))
.catch(err => console.error(err));
Conclusion
The PageCDN API provides a simple interface for optimizing website performance. With this API, you can streamline your workflows and automate many common tasks. We hope this article has provided a useful overview of the PageCDN API.