# Get Image v1.0

The Get Image endpoint retrieves image meta-data for an image. It is useful to see the sizes of the images and to construct a URL that can be used to resize the image on the fly as it is downloaded. The request returns meta-data for an image including the full URL path to download the image via our CDN.

Image Downloads

This endpoint does not return the image itself. The image must be downloaded from our CDN using the URLs provided in the Menu API. The parameters described below all work with the CDN URL provided in the Menu API.

# Request

GET /image-api/v1.0/images/{key}[?height][&width][&quality][&attachment]

# Path Parameters

A list of the supported path parameters is described below.

Name Required Type Description
key true string The unique key for the image. The key is made available in Menu API resources.

# Query Parameters

The query parameters will be used to construct a full URL that can be used to download the image. The url property on the imageDetails resource will contain the full URL.

A list of the supported query parameters is described below.

Name Required Type Description
height false int A height to use when resizing the image. Value is number of pixels.
width false int A width to use when resizing the image. Value is number of pixels.
quality false int JPEG only JPEG images support setting the quality. For large images this reduces the size significantly. Ignored on all other images types.

Valid values are from 1 to 100. 100 is full quality which is the default.
attachment false boolean By default the API returns the image with a Content-Disposition header of inline suitable for display on websites. If preferred, this can be set to attachment which will ask the browser to download the image as an attachment.

# Response

200
OK
Returns an ImageDetails resource wrapped in an ApiResponse envelope.

# Response Body

The endpoint returns our ApiResponse envelope. The data property of the response will contain a single ImageDetails resource.

# ImageDetails

Provides meta data for an image.

Name Required Type Description
key true string The unique key for the image.
contentType false string The content type for the image.
width false int The width of the original image in pixels.
height false int The height of the original image in pixels.
size true int The size of the original image in bytes. The image may be a different size when downloaded via the CDN due to how the image processor works.
originalFileName false string The original file name of the image when it was uploaded.
url true string The URL to retrieve the image from the CDN. The CDN supports both HTTP as well as HTTPS for serving the image.

The query parameters from the request will be added, if supplied.
createdOn false date-time An ISO 8601 formatted date string specifying the date and time when the the original image was uploaded.
modifiedOn false date-time An ISO 8601 formatted date string specifying the date and time when the the original image was last modified.

# Sample

{
    "message": "The operation succeeded!",
    "notifications": [],
    "data": {
        "key": "54C006D5-9F04-4885-BB5B-E32E7FC0F7FB",
        "contentType": "image/png",
        "width": 600,
        "height": 600,
        "size": 380429,
        "originalFileName": "some-name.png",
        "url": "images.spurcorp.com/54C006D5-9F04-4885-BB5B-E32E7FC0F7FB?width=450",
        "createdOn": "2020-05-18T13:30:04Z",
        "modifiedOn": "2020-05-18T19:49:38Z"
    }
}

# Response Headers

Content-Disposition: inline 

Or if attachment query parameter is used:

Content-Disposition: attachment 

# Errors

The standard error responses apply.

404
Not Found
When the image cannot be found.

# Examples

# Basic Request

An example of a basic request with no additional parameters.

# Request

GET /image-api/v1.0/images/54C006D5-9F04-4885-BB5B-E32E7FC0F7FB

# Response

{
    "message": "The operation succeeded!",
    "notifications": [],
    "data": {
        "key": "54C006D5-9F04-4885-BB5B-E32E7FC0F7FB",
        "contentType": "image/png",
        "width": 600,
        "height": 600,
        "size": 380429,
        "originalFileName": "some-name.png",
        "url": "images.spurcorp.com/54C006D5-9F04-4885-BB5B-E32E7FC0F7FB",
        "createdOn": "2020-05-18T13:30:04Z",
        "modifiedOn": "2020-05-18T19:49:38Z"
    }
}

# Request With Width Parameter

An example of a basic request with width query parameter provided.

# Request

GET /image-api/v1.0/images/54C006D5-9F04-4885-BB5B-E32E7FC0F7FB?width=450

# Response

{
    "message": "The operation succeeded!",
    "notifications": [],
    "data": {
        "key": "54C006D5-9F04-4885-BB5B-E32E7FC0F7FB",
        "contentType": "image/png",
        "width": 600,
        "height": 600,
        "size": 380429,
        "originalFileName": "some-name.png",
        "url": "images.spurcorp.com/54C006D5-9F04-4885-BB5B-E32E7FC0F7FB?width=450",
        "createdOn": "2020-05-18T13:30:04Z",
        "modifiedOn": "2020-05-18T19:49:38Z"
    }
}