Admin API Reference

The Admin API is for managing Compress API keys and Easy IO CDN sites. The hostname is optimize.exactlywww.com and must be accessed by HTTPS. All requests to the API must use the POST method and include a user-agent. All responses will be JSON-encoded.

Authentication

To use the API, you must provide an API key. Sub-keys naturally cannot create other sub-keys, but may be used to create CDN sites/zones. The POST parameter api_key must be set to a valid API key for both Easy IO and Compress API management.

Easy IO Show Sites – /exactdn/show.php

To display detail about existing CDN sites on your account, use https://optimize.exactlywww.com/exactdn/show.php

This endpoint will normally return data for all sites your account, or related sites for a sub-key. You may provide an optional site_url parameter to filter the results to a single site.

The response will look something like this:

array(
	'live_sites' => 1,
	'sites'      => array(
		[0] => array(
			'site_id'   => '17',
			'zone'      => 'earqb5e5seg',
			'alias'     => 'earqb5e5seg.exactdn.com',
			'site_url'  => 'https://www.example.net/',
			'location'  => 'NA,US',
			'pending'   => false,
			'live'      => '1',
			'purgeable' => '1',
			'bandwidth' => '3935162323',
			'beforet'   => 'https://gtmetrix.com/reports/www.example.net/Wsv1hIOf/',
			'aftert'    => 'https://gtmetrix.com/reports/www.example.net/jgeylNvw/',
			'config'    => array(
				'avif'               => 0,
				'webp'               => 1,
				'asset_domains'      => 'images.third-party.net',
				'watermark'          => 0,
				'watermark_offset'   => 0,
				'watermark_min_size' => 300,
				'watermark_position' => 0,
				'watermark_url'      => 'https://www.example.net/images/watermark.png',
			),
		),
	),
	'licensed' => '10',
	'interval' => 'month',
	'quota' => 2000000000000,
)

Which gives some detail about account limits, and then an array of sites with relevant details:

  • live_sites - The number of sites that count toward the account quota, any sites where live = 0 do not affect the site limits.
  • licensed - The number of sites an account may have. Sub-keys may have their own limits and default to 0 (no limit).
  • interval - The renewal interval: month, year, or life. Sub-keys will not show the interval.
  • quota - The amount of bandwidth allowed for the account in bytes.
  • sites - An array of sites with the following detail:
    • site_id - The unique identifier for a given Easy IO site.
    • zone - The backend CDN zone name. Will match the alias unless a custom hostname/alias is applied.
    • alias - The CDN hostname for the site/zone.
    • site_url - The origin URL for the CDN zone.
    • location - The detected geographic location of the origin server. This affects whether images are processed via the North America, Europe, or Oceania server location.
    • pending - For new sites, this will be true. Sites that are pending cannot be removed.
    • live - Whether a given site is live/production or dev/staging. If a given site is not detected correctly, contact support.
    • purgeable - 1 = site cache may be purged, 0 = no purging allowed. Normally set to 1 except in extreme cases.
    • bandwidth - The amount of bandwidth a site has consumed in the last 30 days, in bytes.
    • beforet - The URL of the site performance test, run when a site was first added to the account.
    • aftert - The URL of the performance test, run after Easy IO is activated on a given site.
    • config - An array with the current site configuration.

Try it out with cURL (replacing ‘abc123’ with your own key):

curl --data api_key=abc123 --data token=abc123 https://optimize.exactlywww.com/exactdn/show.php

Easy IO Add/Create Site – /exactdn/create.php

To add a site to your account, submit a request with your API key and the origin URL. Requests are sent to  https://optimize.exactlywww.com/exactdn/create.php

Here is an example with cURL:

curl --data api_key=abc123 --data token=abc123 --data site_url='https://www.example.com/' https://optimize.exactlywww.com/exactdn/create.php

The response is JSON-encoded with the following data:

  • id - The unique identifier for the new site.
  • site_url - The origin URL, which should match what was provided, though trailing slashes will be added if missing.
  • dev - 1/0: a value of 1 means the site is assumed to be a development/staging site and will not count against the site limit.
  • alias - The CDN hostname generated for this site.
  • status - Will always be 'success'.

If there is an error, the response will be an array with a single 'error' item that includes an error message:

array(
	'error' => 'site URL not provided'
)

Easy IO Update Site Configuration – /exactdn/config-update.php

To change the site (CDN zone) configuration, submit a request with your API key, the site ID, and the desired configuration parameters. Use the /exactdn/show.php endpoint to retrieve a given site ID along with the existing site configuration.

Requests should be sent to https://optimize.exactlywww.com/exactdn/config-update.php

Here is an example with cURL:

curl --data api_key=abc123 --data site_id=16 --data webp=1 --data avif=1 https://optimize.exactlywww.com/exactdn/config-update.php

The response is JSON-encoded with the following data:

array(
	'success'   => 1,
 	'webp'      => 1,
 	'avif'      => 1,
	'asset_domains' => 'images.third-party.net',
 	'watermark' => 0,
	'watermark_offset'   => 0,
	'watermark_min_size' => 300,
	'watermark_position' => 0,
	'watermark_url'      => 'https://www.example.net/images/watermark.png',
)

Watermark positions are as follows:

1 = Top Left

2 = Top Right

3 = Bottom Left

4 = Bottom Right

5 = Center

Errors will be given in exactly the same form as Site Create requests.

Easy IO Add Custom Hostname (CNAME) – /exactdn/cname.php

To change the CDN hostname, submit a request with your API key, the site ID, and the desired CNAME/hostname. Requests should be sent to https://optimize.exactlywww.com/exactdn/cname.php

Here is an example with cURL:

curl --data api_key=abc123 --data site_id=16 --data custom_cname='cdn.example.net' https://optimize.exactlywww.com/exactdn/cname.php

The response is JSON-encoded with the following data:

array(
	'success' => 'Custom hostname successfully added.',
 	'alias'   => 'cdn.example.net',
)

Errors will be given in exactly the same form as Site Create requests.

Easy IO Remove Custom Hostname (CNAME) – /exactdn/cname-revert.php

To remove a custom hostname and restore the standard CDN hostname, submit a request with your API key and the site ID to https://optimize.exactlywww.com/exactdn/cname-revert.php

Here is an example with cURL:

curl --data api_key=abc123 --data site_id=16 https://optimize.exactlywww.com/exactdn/cname-revert.php

The response is JSON-encoded with the following data:

array(
	'success' => 'Default hostname successfully restored: e5f5jkjh5x8.exactdn.com',
 	'alias'   => 'e5f5jkjh5x8.exactdn.com',
)

Errors will be given in exactly the same form as Site Create requests.

Easy IO Remove Site – /exactdn/remove.php

To remove a site, submit a request with your API key and the site ID. Use the /exactdn/show.php endpoint to retrieve a given site ID. Requests should be sent to https://optimize.exactlywww.com/exactdn/remove.php

Here is an example with cURL:

curl --data api_key=abc123 --data token=abc123 --data site_id=18 https://optimize.exactlywww.com/exactdn/remove.php

Errors will be given in exactly the same form as Site Create requests, but a success will look like this:

array(
	'success' => true
)

Easy IO Stats – /exactdn/savings.php

To view the image savings & statistics for a site, submit a request with the CDN alias. Requests should be sent to https://optimize.exactlywww.com/exactdn/savings.php

Here is an example with cURL:

curl --data alias='example.exactdn.com https://optimize.exactlywww.com/exactdn/savings.php

Errors will be given for a missing/invalid alias in the same format, but a successful response will look this:

array(
	'original'  => 987654321,
	'savings'   => 623451789,
	'quota'     => 200000000000,
	'bandwidth' => 142399842,
)

Compress API Show Keys – /api_key/show.php

To display detail about the sub-keys available on your account, use  https://optimize.exactlywww.com/api_key/show.php

The response will look something like this:

array(
	"keys" => array(
		"xyz456",
		"kjh38235",
	),
	"limits" => array(
		"xyz456" => "0",
		"kjh38235" => "2000",

	),
	"sites" => array(
		"xyz456":0,
		"kjh38235":0,
	),
	"site_limit" => array(
		"xyz456":"0",
		"kjh38235":"2",
	),
	"labels" => array(
		"xyz456":"example.org",
		"kjh38235":"testing",
	),
	"stats" => array(
		"xyz456" => array(
			"2022-06":"0",
			"2020-04":"146",
			"2020-03":"149",
		),
		"kjh38235" => array(
			"2022-06":"0",
			"2021-11":"71",
			"2021-02":"21",
		),
	),
	"bill" => array(
		"xyz456" => array(
			"2020-04":"$0.99",
			"2020-03":"$0.99",
			"2020-02":"$0.99",
		),
		"kjh38235" => array(
			"2021-11":"$0.99",
			"2021-02":"$0.99",
			"2020-11":"$0.99",
		),
	),
)

This gives us detail about account limits, labels, etc. using the keys themselves (from the 'keys' array) as the indexes:

  • keys - A list of all the sub-keys for the account.
  • limits - The number of images a sub-key may optimize in a single month.
  • sites - The number of (production) sites active for a given sub-key. Easy IO only for now, sub-keys cannot currently activate the SWIS plugin yet.
  • site_limits - The number of sites a sub-key may create/activate. Default is 0 (no limit).
  • labels - The labels assigned to each key, empty by default.
  • stats - The number of Compress API credits used for each month. Months with no usage will not be returned.
  • bill - The retail value of the credits used for the given period.

Try it out with cURL (replacing ‘abc123’ with your own key):

curl --data api_key=abc123 https://optimize.exactlywww.com/api_key/show.php

Compress API Add/Create (Sub)Key – /api_key/create.php

To add a sub-key to your account, submit a request with your API key. Requests should be sent to  https://optimize.exactlywww.com/api_key/create.php

Here is an example with cURL:

curl --data api_key=abc123 https://optimize.exactlywww.com/api_key/create.php

success will look like this:

array(
	'success' => 1,
	'sub_key' => 'xyz456',
)

Whereas an error will be shown like this:

array(
	'error' => 'API key not found'
)

Compress API Remove (Sub)Key – /api_key/remove.php

To remove a sub-key from your account, submit a request with your API key and the sub-key. Requests should be sent to https://optimize.exactlywww.com/api_key/remove.php

Here is an example with cURL:

curl --data api_key=abc123 --data sub_key=xyz456 https://optimize.exactlywww.com/api_key/remove.php

success will look like this:

array(
	'success' => 1,
	'sub_key' => 'xyz456',
)

Errors will be returned in the same format as above for a /create.php request.

Compress API Change (Sub)Key – /api_key/change.php

To modify the label/limits for a sub-key, submit a request with your API key and the sub-key along with the data to modify (omitted fields will be set to empty values). Requests should be sent to https://optimize.exactlywww.com/api_key/change.php

Here is an example with cURL:

curl --data api_key=abc123 --data sub_key=xyz456 --data label='forfun' --data allowed=5000 --data site_limit=10 https://optimize.exactlywww.com/api_key/change.php

success will look like this:

array(
	'success'    => 1,
	'sub_key'    => 'xyz456',
	'label       => 'forfun',
	'allowed'    => 5000,
	'site_limit' => 10,
)

Errors will be returned in the same format as above for a /create.php request.

Have an idea, or need help?

If you have any questions, suggestions, or ideas about the API, feel free to contact us.

Still need help? Contact Us Contact Us