Variants
Variants allow automatic transformations of property values when accessed via the API. Create variants on string or blob properties to generate transformed versions on-demand.
How Variants Work
- Create a variant on a property (
stringorblob) - Define one or more transformation steps
- Access the transformed value using
$variantNamesyntax - Results are cached for performance
Available Transformers
| Transformer | Property Type | Description |
|---|---|---|
| Translate | string | Translate text to different languages |
| Vision AI Image Description | blob | Generate AI descriptions of images |
| Image Resize | blob | Resize images to specific dimensions |
| Image Grayscale | blob | Convert images to grayscale |
Creating Variants
In the Developer Portal
- Navigate to your collection
- Select a
stringorblobproperty - Click Add Variant
- Name your variant (e.g., "thumbnail", "spanish")
- Add transformation steps
- Save
Chaining Transformers
Each variant can have multiple transformation steps applied in sequence:
Original Image → Resize (200x200) → Grayscale → Output
This allows complex transformations like "resize then convert to grayscale" in a single variant.
Accessing Variants
Blob Properties (Images/Files)
Append the variant name to the blob field URL:
GET https://eu.restapi.com/my-api/products/<item-id>/image$thumbnail
Examples:
/products/abc-123/image$thumbnail # Resized thumbnail
/products/abc-123/photo$grayscale # Grayscale version
/products/abc-123/image$small # Custom "small" variant
String Properties (Text)
Use the select parameter with the variant name:
GET https://eu.restapi.com/my-api/articles/<item-id>?select=description$spanish
Examples:
?select=content$spanish # Translated to Spanish
?select=description$summary # Summarized version
?select=title,content$translated # Multiple fields with variant
Multiple Variants
Request multiple variants in a single call:
GET https://eu.restapi.com/my-api/articles/abc-123?select=title,content$summary,content$spanish
Returns the title plus both a summarized and translated version of content.
Use Cases
Image Transformations
| Use Case | Example Variant |
|---|---|
| Thumbnails | Resize to 150x150 |
| Responsive images | Multiple size variants (small, medium, large) |
| Optimized formats | Convert to WebP |
| Grayscale previews | Remove color |
Text Transformations
| Use Case | Example Variant |
|---|---|
| Multilingual content | Translate to Spanish, French, German |
| Content previews | Summarize long articles |
| Accessibility | Generate image descriptions |
Benefits
| Benefit | Description |
|---|---|
| No code required | Configure in the portal, no functions needed |
| Cached results | Transformed content is cached automatically |
| On-demand | Only generated when first requested |
| Scalable | Runs on serverless infrastructure |
Example: Product Images
Create variants for different image sizes:
| Variant Name | Transformation |
|---|---|
thumbnail | Resize to 100x100 |
card | Resize to 300x200 |
detail | Resize to 800x600 |
hero | Resize to 1920x1080 |
Access them:
/products/abc-123/image # Original
/products/abc-123/image$thumbnail # 100x100
/products/abc-123/image$card # 300x200
/products/abc-123/image$detail # 800x600
Example: Multilingual Content
Create translation variants for an article's description:
| Variant Name | Transformation |
|---|---|
spanish | Translate to Spanish |
french | Translate to French |
german | Translate to German |
Access them:
?select=description # Original language
?select=description$spanish # Spanish translation
?select=description$french # French translation