Image - Introduction
Base URL
- AWS North America (AWS NA): https://images.contentstack.io/
- AWS Europe (AWS EU): https://eu-images.contentstack.com/
- AWS Australia (AWS AU): https://au-images.contentstack.com/
- Azure North America (Azure EU): https://azure-na-images.contentstack.com/
- Azure Europe (Azure EU): https://azure-eu-images.contentstack.com/
- GCP North America (GCP NA): https://gcp-na-images.contentstack.com/
- GCP Europe (GCP EU): https://gcp-eu-images.contentstack.com/
Overview
Contentstack’s Image Delivery API allows you to manipulate images stored in your content types. This API lets you perform various transformations on your images, such as resizing, cropping, changing the format etc.
Supported input formats
- JPEG
- PNG
- WEBP
- GIF
- AVIF
Supported output formats
- JPEG (baseline & progressive)
- PNG
- WEBP (lossy & lossless)
- GIF
- AVIF
If you are looking for APIs to deliver content to your web or mobile properties, use our Content Delivery API, and to manage content, you should use the Content Management API.
Rate Limiting
Rate limiting defines the maximum number of API requests your organization can make within a specific time frame.
Request Types
• CDN Requests: Contentstack’s CDN serves cached responses. These requests are not subject to rate limiting.
• Origin Server Requests: Requests that are not cached and are routed to the origin server are subject to rate limits.
Default Limits
By default, origin server requests are limited to 80 requests per second per organization. All requests made from the CDA and Image Delivery API endpoints counts towards this rate limit excluding GraphQL. The exact rate limit depends on your plan. If required, you can request an increase by contacting support.
NoteWhile CDN requests are not rate-limited, all API requests (CDN and origin) count toward your organization’s overall API usage quota.
Rate Limit Exceeded
If your application exceeds the allowed rate limit within a given time period, the API will return an HTTP 429 (Too Many Requests) response.
Monitoring Rate Limits
You can track your current rate limit status using the HTTP response headers returned with each API request. These limits reset at the beginning of each time window.
| Headers | Description |
|---|---|
| X-RateLimit-Limit | Maximum number of requests allowed per second per organization. |
| X-RateLimit-Remaining | Number of requests remaining in the current time window. |
How Image Delivery APIs Work
Image Delivery APIs retrieve, manipulate and/or convert the retrieved image file, and deliver it to your web or mobile properties.
Note The APIs do not modify the actual source image file in Contentstack.
Making a Request
You can use Image Delivery APIs by just appending queries to the image URL: {image_url}?environment={environment_name}&query_parameter
For example, to resize the width of an image to 100px, you need to append {&width={100} to the image URL. So, the API request would be:
https://images.contentstack.io/v3/assets/blteae40eb499811073/bltc5064f36b5855343/59e0c41ac0eddd140d5a8e3e/owl.jpg?environment=production&width=100
You can also use multiple queries in a single API request.
{image_url}?environment={environment_name}&width={width_value}&height={height_value}&resize-filter={resize-filter_value}In this case, the API request would form like this:
https://images.contentstack.io/v3/assets/blteae40eb499811073/bltc5064f36b5855343/59e0c41ac0eddd140d5a8e3e/owl.jpg?environment=production&width=500&height=550&resize-filter=nearest
Include Environment Parameter
When making Image Delivery API requests, you must include the environment query parameter:
{image_url}?environment={environment_name}&query_parameterUsing the environment parameter ensures that requests are routed through Contentstack’s Content Delivery Network (CDN). This approach provides the following benefits:
- Avoids routing requests through the Content Management API (CMA), which can cause rate limit errors and timeouts.
- Ensures higher rate limits and lower costs by serving images directly from the CDN.
NoteThe image must be published in the environment which is being passed as a query parameter.
Understanding Different Strings in the Asset URL
Here’s an example of an asset URL:
https://images.contentstack.io/v3/assets/blteae40eb499811073/bltc5064f36b5855343/59e0c41ac0eddd140d5a8e3e/owl.jpg
If you notice the URL, you will see that it is made up of several strings. Here's the breakdown of these strings to understand what they are:
{base_url}/v3/assets/{stack_api_key}/{asset_uid}/{file_uid}/filenameAdditional ResourceRefer to Understanding Asset URL document to know more about asset URL structure.
Please note that the above breakdown of strings of the asset URL is just for your understanding. This is the default pattern of all the asset URLs.
If the "Branches" feature is part of your plan, you will see an updated download URL format for all assets part of any branch, except the default main branch. The branch={branch_UID} query parameter is attached to the download URL.
For instance, if you upload an asset to the development branch, Contentstack generates the following asset download URL:
https://assets.contentstack.com/v3/assets/blt252b550c5ccdae26/bltc56f275260214c0b/61280d9625aca65092ce7f15/Sample_Image.jpg?branch=development
For any asset that you upload to the main branch, Contentstack will continue to generate asset download URLs in the earlier format:
https://assets.contentstack.com/v3/assets/blt252b550c5ccdae26/bltc56f275260214c0b/61280d9625aca65092ce7f15/Sample_Image.jpg
When working with this API documentation, you do not have to enter any of the above values. To make Image Delivery API requests, you simply need to append queries to the asset URL.
Limitations with Optimizing Image
- The maximum input image file size is 50 MB
- The maximum input image dimension is 12,000x12,000 pixels
- The maximum output image dimension is 8,192x8,192 pixels (8K Ultra HD)
- The maximum number of frames an animated GIF can contain is 1,000
- The maximum output image area for AVIF images is 4,096 x 4,096 pixels