ShortPixel's CDN - API endpoints

If you plan on using ShortPixel Adaptive Images or other partner plugins and you want to associate domains, remove them or read their usage data in a programmatic fashion here's how you can achieve that. 

We will use example.com as example domain, and APIkey as example API key.

Adding a new domain

Adds a new domain into the system. If you're not sure whether the domain was already associated you can safely try to associate it again.

https://no-cdn.shortpixel.ai/add-domain/example.com/APIkey
  • If both the domain and the API Key are present, the domain will be added and associated to the user having that API key.
  • If the API Key is missing, the domain will be added but will be associated to no user, and therefore the user will only be able to use up to 500 free credits.
  • If the domain was already added but had no associated user, and a new call with an API Key is made, then the domain will be associated to the user with that API Key.
  • If a domain is added and already associated with a user, then a new API call for that domain but with a different user will not work for security reasons.

Reading the domain data

To check what's the status of a domain and its quota, you should use

https://no-cdn.shortpixel.ai/read-domain/example.com

The statuses can be

  • 2 = All OK
  • 1 = Credits almost used
  • -1 = Credits exhausted
  • -2 = Credits exhausted a longer time ago (can be used to stop using the CDN links, for example)
  • -3 = Domain not reachable

Setting a domain

This endpoint works pretty much like Adding a new domain except it will not add a domain. Instead, it will only associate a user ID, if not already associated.

https://no-cdn.shortpixel.ai/set-domain/example.com/APIkey

Revoke a domain association

It revokes a domain association. It only works when the API Key of the current domain owner is presented.

https://no-cdn.shortpixel.ai/revoke-domain/example.com/APIkey

Available credits

This returns how many available credits the API key has.

http://api.shortpixel.com/v2/api-status.php?key=APIkey

The fields are:

  • Status: if the request has been made successfully or not (wrong API key?)
  • APICallsMade: the number of paid API calls (optimized more than 5%) the user has made from his monthly quota
  • APICallsFree: the number of free API calls (optimized less than 5%) the user has made
  • APICallsQuota: the user's monthly quota
  • APICallsQuotaOneTime: the user's one-time credits quota
  • APICallsMadeOneTime: the number of paid API calls (optimized more than 5%) the user has made from his one-time credits
  • DateSubscription: the date when the subscription was created
  • DomainCheck: is the domain accessible by ShortPixel servers?

Example of the response:

{ "Status": { "Code": "2", "Message": "Success" }, "APICallsMade": "0", "APICallsFree": "0", "APICallsQuota": 250, "APICallsQuotaOneTime": "10517", "APICallsMadeOneTime": "517", "DateSubscription": "2020-09-17 00:03:54", "DomainCheck": "Accessible" }

CDN Usage & additional stats

The response of the following URL will contain stats about the CDN usage and API calls of the domain.

https://no-cdn.shortpixel.ai/read-domain-cdn-usage/example.com/APIkey

The fields are:

  • Email: the email of the user
  • APIQuota: the user's monthly quota
  • APIQuotaOneTime: the user's one-time credits quota
  • FreeAPICalls: the number of free API calls (optimized less than 5%) the user has made
  • PaidAPICalls: the number of paid API calls (optimized more than 5%) the user has made from his monthly quota
  • PaidAPICallsOneTime: the number of paid API calls (optimized more than 5%) the user has made from his one-time credits
  • CDNQuota: the total quota of the user
  • UsedCDN: monthly breakdown of the used CDN quota by the user
  • UsedCredits: monthly breakdown of the used credits by the user

Example of the response:

{ "Email": "test@shortpixel.com", "APIQuota": 10000, "APIQuotaOneTime": "181375", "FreeAPICalls": "1155", "PaidAPICalls": "10000", "PaidAPICallsOneTime": "181415", "CDNQuota": 107374182400, "UsedCDN": { "2020-04-22": { "Traf": 76549683336 }, "2020-04-23": { "Traf": 105350265409 }, "2020-04-24": { "Traf": 86034361003 }, "2020-04-25": { "Traf": 86981426571 }, "2020-04-26": { "Traf": 93787223741 }, "2020-04-27": { "Traf": 82380836532 }, "2020-04-28": { "Traf": 78674982444 }, "2020-04-29": { "Traf": 80999774419 }, "2020-04-30": { "Traf": 90278674065 }, "2020-05-01": { "Traf": 78779372848 }, "2020-05-02": { "Traf": 87318692243 }, "2020-05-03": { "Traf": 90744831529 }, "2020-05-04": { "Traf": 78609523291 }, "2020-05-05": { "Traf": 81044339811 }, "2020-05-06": { "Traf": 69092312964 }, "2020-05-07": { "Traf": 65019719545 }, "2020-05-08": { "Traf": 67454258761 }, "2020-05-09": { "Traf": 73135562343 }, "2020-05-10": { "Traf": 70445768181 }, "2020-05-11": { "Traf": 50844361778 }, "2020-05-12": { "Traf": 54374471634 }, "2020-05-13": { "Traf": 55154681599 }, "2020-05-14": { "Traf": 52573310737 }, "2020-05-15": { "Traf": 51264870100 }, "2020-05-16": { "Traf": 47930615941 }, "2020-05-17": { "Traf": 53491523437 }, "2020-05-18": { "Traf": 54880287346 }, "2020-05-19": { "Traf": 46898521300 }, "2020-05-20": { "Traf": 43073615533 }, "2020-05-21": { "Traf": 19590657074 } }, "UsedCredits": { "2020-04-02": { "Paid": 166, "Free": 50 }, "2020-04-03": { "Paid": 393, "Free": 36 }, "2020-04-04": { "Paid": 180, "Free": 40 }, "2020-04-05": { "Paid": 253, "Free": 41 }, "2020-04-06": { "Paid": 245, "Free": 58 }, "2020-04-07": { "Paid": 217, "Free": 28 }, "2020-04-08": { "Paid": 234, "Free": 37 }, "2020-04-09": { "Paid": 164, "Free": 32 }, "2020-04-10": { "Paid": 304, "Free": 48 }, "2020-04-11": { "Paid": 143, "Free": 34 }, "2020-04-12": { "Paid": 230, "Free": 109 }, "2020-04-13": { "Paid": 407, "Free": 129 }, "2020-04-14": { "Paid": 441, "Free": 50 }, "2020-04-15": { "Paid": 156, "Free": 34 }, "2020-04-16": { "Paid": 56, "Free": 37 }, "2020-04-17": { "Paid": 322, "Free": 59 }, "2020-04-18": { "Paid": 140, "Free": 58 }, "2020-04-19": { "Paid": 349, "Free": 53 }, "2020-04-20": { "Paid": 587, "Free": 60 }, "2020-04-21": { "Paid": 491, "Free": 40 }, "2020-04-22": { "Paid": 116, "Free": 35 }, "2020-04-23": { "Paid": 222, "Free": 73 }, "2020-04-24": { "Paid": 1416, "Free": 136 }, "2020-04-25": { "Paid": 1097, "Free": 77 }, "2020-04-26": { "Paid": 903, "Free": 74 }, "2020-04-27": { "Paid": 804, "Free": 70 }, "2020-04-28": { "Paid": 1218, "Free": 174 }, "2020-04-29": { "Paid": 2683, "Free": 205 }, "2020-04-30": { "Paid": 1052, "Free": 82, "Orig": 15078906, "Opt": 10182044 }, "2020-05-01": { "Orig": 34997309, "Opt": 21666182, "Paid": 903, "Free": 176 }, "2020-05-02": { "Orig": 27678626, "Opt": 16676540, "Paid": 360, "Free": 53 }, "2020-05-03": { "Orig": 3092886, "Opt": 2139760, "Paid": 63, "Free": 6 }, "2020-05-04": { "Orig": 40896, "Opt": 7916, "Paid": 40, "Free": 0 } } }<br>

Still need help? Contact Us Contact Us