Measura API documentation · v1
Retrieve a specific variant by product ID and variant ID.
GET /api/v1/products/{productId}/variants/{variantId}
Headers:
Authorization: Bearer <api-key>
Content-Type: application/jsonScroll horizontally to see all columns.
| Parameter | Type | Description |
|---|---|---|
productId | string | Required - The Shopify product REST ID |
variantId | string | Required - The Shopify variant REST ID |
Scroll horizontally to see all columns.
| Parameter | Type | Description |
|---|---|---|
location_id | string (optional) | Positive numeric Shopify location REST ID. Include it to add current measured inventory for one location. Omit it to preserve the existing response and five-minute cache. |
{
"success": true,
"data": {
"variant": {
"id": "456",
"isMeasuraEligible": true,
"fractionalInventory": { "123456": { "quantity": 0.25 } },
"inventory": {
"locationId": "123456",
"tracked": true,
"available": { "quantity": 12.25, "unit": "kg" }
},
"unitMeasurement": {
"unit": "kg",
"value": 1
},
"settings": {
"onlineStore": {
"displayStyle": "number",
"rules": {
"min": 0.5,
"increment": 0.5,
"defaultValue": 1
}
}
},
"product": {
"id": "123",
"measurementType": "weight"
}
}
},
"error": null
}Scroll horizontally to see all columns.
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates whether the request was successful |
data | object | Response data object |
error | null | Null for a successful request |
data.variant.inventory | object (optional) | Present only with location_id. The example includes location_id=123456 and Shopify available stock of 12 plus a 0.25 remainder. |
data.variant.inventory.locationId | string | Requested Shopify location REST ID. |
data.variant.inventory.tracked | boolean | Whether Shopify tracks this inventory item. |
data.variant.inventory.available | object | null | Measured quantity and unit. Null when untracked or not stocked at this location; zero is a real balance. |
data.variant.inventory.available.quantity | number | Shopify available stock plus its owned fractional remainder, multiplied by unitMeasurement.value. Negative quantities are preserved. |
data.variant.inventory.available.unit | string | The configured unitMeasurement.unit, for example kg or g. |
data.variant | Variant | The variant object |
Scroll horizontally to see all columns.
| Status code | Description |
|---|---|
| 400 | Bad Request - Missing product ID or variant ID, or invalid location_id (including an empty value or a GID) |
| 401 | Unauthorized - Missing or invalid API key |
| 403 | Forbidden - Public API access is unavailable for this shop |
| 422 | Unprocessable Entity - Product is not configured for sell-by-measurement, or a location-specific read targets a variant excluded from Measura |
| 429 | Too Many Requests - API rate limit exceeded |
| 404 | Not Found - Unknown location, missing variant, or variant does not belong to the specified product |
| 500 | Internal Server Error - Server error while processing the request |
Note
For current stock, request /api/v1/products/123/variants/456?location_id=123456. The example above shows this opt-in response. Without location_id, inventory is omitted and the existing private five-minute cache applies. With location_id, response caches are bypassed and Cache-Control is no-store.
fractionalInventory keeps its existing map of fulfillment-location remainders, even when location_id is supplied. It is not filtered to the requested location. The new inventory field can also read a location outside that fulfillment list.
Availability is measured available stock, not on-hand stock or a reservation. For 12 Shopify units plus 0.75 remainder at 100 g per stock unit, available is 1275 g. Negative remainders from upward rounding are valid. Configuration still uses the existing settings cache; a concurrent inventory write may be in progress.
Untracked inventory returns tracked=false and available=null. A tracked item without a stock level at this location returns tracked=true and available=null. Missing, malformed, or foreign-owned fractional values contribute zero; legacy ownerless values remain accepted.
The variant must belong to the specified product. Without location_id, excluded variants remain readable with isMeasuraEligible=false. A location-specific measured inventory request for an excluded variant returns 422.
Related: