{"id":1005,"date":"2024-05-07T11:49:08","date_gmt":"2024-05-07T11:49:08","guid":{"rendered":"https:\/\/kb.shortpixel.com\/docs\/shortpixels-cdn-api-endpoints\/"},"modified":"2025-08-27T08:37:37","modified_gmt":"2025-08-27T08:37:37","password":"","slug":"shortpixels-cdn-api-endpoints","status":"publish","type":"docs","link":"https:\/\/kb.shortpixel.com\/knowledge-base\/article\/shortpixels-cdn-api-endpoints\/","title":{"rendered":"ShortPixel&#8217;s CDN API endpoints"},"content":{"rendered":"\n<p>If you use <a href=\"https:\/\/wordpress.org\/plugins\/shortpixel-adaptive-images\/\" target=\"_blank\" rel=\"noopener\">ShortPixel Adaptive Images<\/a> or other partner plugins and want to <a href=\"https:\/\/kb.shortpixel.com\/knowledge-base\/article\/how-to-associate-a-domain-to-my-account\/\" target=\"_blank\" data-type=\"docs\" data-id=\"695\" rel=\"noreferrer noopener\">associate<\/a>, remove domains or programmatically read their usage data, you can do so how it&#8217;s described here.\u00a0<\/p>\n\n\n\n<p>We will use <strong>example.com<\/strong> as example domain and <code class=\"inline-code\">APIkey<\/code> as example API Key.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Adding a new domain<\/h2>\n\n\n\n<p>Adds a new domain&nbsp;to the system.&nbsp;If you are not sure whether the domain was already associated, you can safely try to associate it again.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">https:\/\/no-cdn.shortpixel.ai\/add-domain\/example.com\/APIkey<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If both the domain and the API Key exist, the domain is added and associated to the user who has that API Key.<\/li>\n\n\n\n<li>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.<\/li>\n\n\n\n<li>If the domain has already been added\u00a0but no user is associated, and a new call is made\u00a0<strong>with<\/strong> an API Key, the domain is associated with the user who has that API Key.<\/li>\n\n\n\n<li>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.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Reading domain data<\/h2>\n\n\n\n<p>To check the status of a domain and its quota, you should use the following.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">https:\/\/no-cdn.shortpixel.ai\/read-domain\/example.com<\/pre>\n\n\n\n<p>The statuses can be<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>2<\/code><\/strong> = All OK<\/li>\n\n\n\n<li><strong><code>1<\/code><\/strong> = Credits almost exhausted<\/li>\n\n\n\n<li><strong><code>-1<\/code><\/strong> = Credits exhausted<\/li>\n\n\n\n<li><strong><code>-2<\/code><\/strong> = Credits used up some time ago (can be used e.g. to stop using CDN links)<\/li>\n\n\n\n<li><strong><code>-3<\/code><\/strong> = Domain not reachable<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Setting a domain<\/h2>\n\n\n\n<p>This endpoint&nbsp;works similarly to &#8220;Adding a new domain&#8221;,&nbsp;except that no domain is added here. Instead, only a user ID is associated if it is not already associated.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">https:\/\/no-cdn.shortpixel.ai\/set-domain\/example.com\/APIkey<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Revoke a domain association<\/h2>\n\n\n\n<p>It revokes a domain association. It works only if the API Key of the current domain owner is presented.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">https:\/\/no-cdn.shortpixel.ai\/revoke-domain\/example.com\/APIkey<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Available credits<\/h2>\n\n\n\n<p>Returns how many available credits the API key has.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">http:\/\/api.shortpixel.com\/v2\/api-status.php?key=APIkey<\/pre>\n\n\n\n<p>The fields are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code class=\"inline-code\">Status<\/code>: whether the request was made successfully or not (wrong API key?)<\/li>\n\n\n\n<li><code class=\"inline-code\">APICallsMade<\/code>: the number of paid API calls (optimized by more than 5%) that the user has made from his monthly quota<\/li>\n\n\n\n<li><code class=\"inline-code\">APICallsFree<\/code>: the number of free API calls (optimized less than 5%) made by the user<\/li>\n\n\n\n<li><code class=\"inline-code\">APICallsQuota<\/code>: the user&#8217;s monthly quota<\/li>\n\n\n\n<li><code class=\"inline-code\">APICallsQuotaOneTime<\/code>: the user&#8217;s quota for one-time credits<\/li>\n\n\n\n<li><code class=\"inline-code\">APICallsMadeOneTime<\/code>:\u00a0the number of paid API calls (optimized more than 5%) that the user has made from their one-time credits<\/li>\n\n\n\n<li><code class=\"inline-code\">DateSubscription<\/code>: the date when the subscription was created<\/li>\n\n\n\n<li><code class=\"inline-code\">DomainCheck<\/code>: is the domain reachable by the ShortPixel servers?<\/li>\n\n\n\n<li><code class=\"inline-code\">Unlimited<\/code>: is the subscription an unlimited one?<\/li>\n<\/ul>\n\n\n\n<p>Example response:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{ \"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\" }<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">CDN usage &amp; additional statistics<\/h2>\n\n\n\n<p>The response to the following URL contains statistics about the CDN usage and API calls of the domain.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">https:\/\/no-cdn.shortpixel.ai\/read-domain-cdn-usage\/example.com\/APIkey<\/pre>\n\n\n\n<p>The fields are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code class=\"inline-code\">Email<\/code>: the user&#8217;s email<\/li>\n\n\n\n<li><code class=\"inline-code\">APIQuota<\/code>: the user&#8217;s monthly quota<\/li>\n\n\n\n<li><code class=\"inline-code\">APIQuotaOneTime<\/code>: the user&#8217;s quota for one-time credits<\/li>\n\n\n\n<li><code class=\"inline-code\">DaysToReset<\/code>: the number of days until the monthly quota is reset<\/li>\n\n\n\n<li><code class=\"inline-code\">IsSubaccount<\/code>: whether the account is actually a subaccount of another one<\/li>\n\n\n\n<li><code class=\"inline-code\">IsAlias<\/code>: whether the API Key is an alias of the main one<\/li>\n\n\n\n<li><code class=\"inline-code\">RemainingCDNTraffic<\/code>: the remaining CDN traffic quota for this domain<\/li>\n\n\n\n<li><code class=\"inline-code\">UsedCDNTraffic<\/code>: how much CDN traffic has the user used in the current month<\/li>\n\n\n\n<li><code class=\"inline-code\">FreeAPICalls<\/code>: the number of free API calls (optimized less than 5%) made by the user<\/li>\n\n\n\n<li><code class=\"inline-code\">PaidAPICalls<\/code>: the number of paid API calls (optimized by more than 5%) made by the the user from his monthly quota<\/li>\n\n\n\n<li><code class=\"inline-code\">PaidAPICallsOneTime<\/code>:\u00a0the number of paid API calls (optimized by more than 5%) that the user has made from his one-time quota<\/li>\n\n\n\n<li><code class=\"inline-code\">CDNQuota<\/code>: the total quota of the user<\/li>\n\n\n\n<li><code class=\"inline-code\">Unlimited<\/code>: whether the client has an unlimited monthly subscription<\/li>\n\n\n\n<li><code class=\"inline-code\">UsedCDN<\/code>: monthly breakdown of the user&#8217;s used CDN quota<\/li>\n\n\n\n<li><code class=\"inline-code\">UsedCredits<\/code>: monthly breakdown of the user&#8217;s credits used<\/li>\n<\/ul>\n\n\n\n<p>Example response:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{ \"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 } } }<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Bulk purge storage<\/h2>\n\n\n\n<p>Purge all files stored on ShortPixel storage servers. Returns a status with the result of the operation<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">https:\/\/no-cdn.shortpixel.ai\/purge-storage-bulk\/APIkey\/example.com<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>example.com<\/strong> is handled differently than\u00a0<a href=\"http:\/\/www.example.com\" rel=\"noopener\"><strong>www.example.com<\/strong><\/a>, so you may need to call the API point twice, once for example.com and then for <a href=\"http:\/\/www.example.com\" rel=\"noopener\">www.example.com<\/a><\/li>\n\n\n\n<li>example.com must be associated with the user who has the API Key<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Bulk purge CDN cache &amp; storage<\/h2>\n\n\n\n<p>Purge all files stored on the CDN and on ShortPixel storage servers. Returns a status with the result of the operation<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">https:\/\/no-cdn.shortpixel.ai\/purge-cdn-cache-bulk\/APIkey\/example.com<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>example.com<\/strong> is handled differently than\u00a0<a href=\"http:\/\/www.example.com\" rel=\"noopener\"><strong>www.example.com<\/strong><\/a>, so you may need to call the API point twice, once for example.com and then for <a href=\"http:\/\/www.example.com\" rel=\"noopener\">www.example.com<\/a><\/li>\n\n\n\n<li>example.com must be associated with the user who has the API Key<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;s described here.\u00a0 We will use example.com as example domain and APIkey as example API Key. Adding a new domain Adds a new domain&nbsp;to the system.&nbsp;If you are [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"doc_category":[49],"glossaries":[],"doc_tag":[],"class_list":["post-1005","docs","type-docs","status-publish","hentry","doc_category-reference-documentation"],"blocksy_meta":[],"year_month":"2026-04","word_count":1063,"total_views":"2200","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"admin","author_nicename":"admin_mdli53m5","author_url":"https:\/\/kb.shortpixel.com\/author\/admin_mdli53m5\/"},"doc_category_info":[{"term_name":"Reference documentation","term_url":"https:\/\/kb.shortpixel.com\/knowledge-base\/category\/reference-documentation\/"}],"doc_tag_info":[],"knowledge_base_info":[],"knowledge_base_slug":[],"_links":{"self":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/1005","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/comments?post=1005"}],"version-history":[{"count":1,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/1005\/revisions"}],"predecessor-version":[{"id":1944,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/1005\/revisions\/1944"}],"wp:attachment":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/media?parent=1005"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/doc_category?post=1005"},{"taxonomy":"glossaries","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/glossaries?post=1005"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/doc_tag?post=1005"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}