View Categories

ShortPixel’s CDN API endpoints

If you use ShortPixel Adaptive Images or other partner plugins and want to associate, remove domains or programmatically read their usage data, you can do so how it's described here. 

We will use example.com as example domain and APIkey  as example API Key.

Adding a new domain #

Adds a new domain to the system. If you are 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 exist, the domain is added and associated to the user who has that API Key.
  • If the API Key is missing, the domain is added but not associated with any user, so the user can only use up to 500 free credits.
  • If the domain has already been added but no user is associated, and a new call is made with an API Key, the domain is associated with the user who has that API Key.
  • If a domain has been added and is already associated with a user, a new API call for that domain with a different user will not work for security reasons.

Reading domain data #

To check the status of a domain and its quota, you should use the following.

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

The statuses can be

  • 2 = All OK
  • 1 = Credits almost exhausted
  • -1 = Credits exhausted
  • -2 = Credits used up some time ago (can be used e.g. to stop using CDN links)
  • -3 = Domain not reachable

Setting a domain #

This endpoint works similarly to "Adding a new domain", except that no domain is added here. Instead, only a user ID is associated if it is not already associated.

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

Revoke a domain association #

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

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

Available credits #

Returns how many available credits the API key has.

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

The fields are:

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

Example 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", "Unlimited": "true" }

CDN usage & additional statistics #

The response to the following URL contains statistics 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 user's email
  • APIQuota : the user's monthly quota
  • APIQuotaOneTime : the user's quota for one-time credits
  • DaysToReset : the number of days until the monthly quota is reset
  • IsSubaccount : whether the account is actually a subaccount of another one
  • IsAlias : whether the API Key is an alias of the main one
  • RemainingCDNTraffic : the remaining CDN traffic quota for this domain
  • UsedCDNTraffic : how much CDN traffic has the user used in the current month
  • FreeAPICalls : the number of free API calls (optimized less than 5%) made by the user
  • PaidAPICalls : the number of paid API calls (optimized by more than 5%) made by the the user from his monthly quota
  • PaidAPICallsOneTime : the number of paid API calls (optimized by more than 5%) that the user has made from his one-time quota
  • CDNQuota : the total quota of the user
  • Unlimited : whether the client has an unlimited monthly subscription
  • UsedCDN : monthly breakdown of the user's used CDN quota
  • UsedCredits : monthly breakdown of the user's credits used

Example response:

{ "Email": "test@shortpixel.com", "APIQuota": 0, "APIQuotaOneTime": "0.00000000000", "DaysToReset": 29, "IsSubaccount": 0, "IsAlias": 0, "RemainingCDNTraffic": 0, "UsedCDNTraffic": "0", "FreeAPICalls": "0.00000000000", "PaidAPICalls": "0.00000000000", "PaidAPICallsOneTime": "12.00000000000", "CDNQuota": 0, "Unlimited": "false", "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>

Bulk purge storage #

Purge all files stored on ShortPixel storage servers. Returns a status with the result of the operation

	https://no-cdn.shortpixel.ai/purge-storage-bulk/APIkey/example.com
  • example.com is handled differently than www.example.com, so you may need to call the API point twice, once for example.com and then for www.example.com
  • example.com must be associated with the user who has the API Key

Bulk purge CDN cache & storage #

Purge all files stored on the CDN and on ShortPixel storage servers. Returns a status with the result of the operation

	https://no-cdn.shortpixel.ai/purge-cdn-cache-bulk/APIkey/example.com
  • example.com is handled differently than www.example.com, so you may need to call the API point twice, once for example.com and then for www.example.com
  • example.com must be associated with the user who has the API Key