# Image API v1.x
The Image API is used to provide image meta-data for images served via our CDN.
# Authentication
No authentication is required to download the images from the CDN however an API key is required to access the API. The API key can be sent via a HTTP request header called X-API-Key
followed by the API key.
X-API-Key: your-api-key
The API keys are generated by Spur Corporation. Keys intended for production will not work in staging and visa-versa.
# Environments
The API is currently deployed to the following environments:
Version | Production | Staging |
---|---|---|
Version 1.0 | ✔️ Deployed | ✔️ Deployed |
# Overview
The Image API is used to provide image meta-data. The images themselves are served via our CDN infrastructure which handles image caching and on-the-fly image resizing.
# Images
Only the Menu API data has images. There are no images for restaurants or brands. Various resources within the Menu API provide image data. Items, Sections and Subsection all may contain images that can be used in different scenarios. See the Menu API documentation for how to request the image data.
The image resource that is served by the Menu API provides the image key and a URL to download the image via our CDN. You can use the image directly without needing to call the Image API.
{
"key": "F4270787-591D-4943-AB21-8C841C7E1B9F",
"partnerKey": null,
"imageType": "LandscapeImage",
"url": "images.spurcorp.com/F4270787-591D-4943-AB21-8C841C7E1B9F"
}
# Downloads
The URL is the link to the Image CDN which can be used to download the image. However, should you want to view image meta-data for an image, you can use the Image API Get Image for these purposes.
The CDN supports HTTP and HTTPS so you can use the scheme that makes the most sense to you.
# Resizing
The CDN supports resizing images on the fly. More details can be found at the Get Image documentation but the summary is that you can provide a width or a height and the backing API will resize the image on the way out. Most of the images we provide won’t need to be resized but should the need arise, it is an option.
# Caching
The CDN caches unique URLs on the edge so a penalty occurs the first time an image is downloaded with a specific size AND scheme, but once that image has been retrieved from our backend it will be served from CDN POP edge caches in Cape Town, Johannesburg and many other locations around the world.
Below is an example of the headers returned on the response. The content-disposition
header is set to inline by default. The content-type
and max-age
headers are also populated.
In the example above, the x-cache
header shows that it was not in cache with a value of TCP_MISS
. The below example shows a cache hit with the value of TCP_HIT
when the image is retrieved the second time.