Inventory data object specification for the Cratejoy Merchant API
You can view or modify inventory levels for a given ecommerce product instance. Relevant resources are Product Instances and Inventory resources.
List inventory levels or instances across all product instances
GET
https://api.cratejoy.com/v1/inventory/
GET
https://api.cratejoy.com/v1/product_instances/
List or modify inventory levels for a given product instance
GET
https://api.cratejoy.com/v1/product_instances/{product_instance_id}/inventory/
PUT
https://api.cratejoy.com/v1/product_instances/{product_instance_id}/inventory/
Get inventory levels across all ecommerce products
GET
https://api.cratejoy.com/v1/inventory/
$.ajax({
url: 'https://api.cratejoy.com/v1/inventory/',
method: 'GET'
});
{
"count": 1,
"next": null,
"prev": null,
"results": [
{
"confidence": 10,
"id": 75572205,
"product_id": 75572202,
"product_instance_id": 75572203,
"quantity_on_hand": 0,
"url": "/v1/product_instances/75572203/inventory/"
},
]
}
List all product instances
GET
https://api.cratejoy.com/v1/product_instances/
$.ajax({
url: 'https://api.cratejoy.com/v1/product_instances/',
method: 'GET'
});
{
"count": 1,
"next": null,
"prev": null,
"results": [
{
"id": 882431002,
"price": 2500,
"product_id": 882430998,
"sku": "SQ4324678",
"type": "product_instance",
"url": "/v1/product_instances/882431002/"
},
]
}
Get inventory level for a product instance
GET
http://api.cratejoy.com/v1/product_instances/{instance_id}/inventory
$.ajax({
url: 'https://api.cratejoy.com/v1/product_instances/75572213/inventory/',
method: 'GET'
});
{
"confidence": 10,
"id": 75572214,
"instance": [], // Product Instance resource
"out_of_stock_purchases": true,
"product_id": 75572211,
"product_instance_id": 75572213,
"quantity_on_hand": 221,
"track_inventory": true,
"type": "product_inventory"
}
Modify inventory level for a product instance
PUT
http://api.cratejoy.com/v1/product_instances/{instance_id}/inventory
$.ajax({
url: 'https://api.cratejoy.com/v1/product_instances/75572213/inventory/',
method: 'PUT',
data: {
quantity_on_hand: 300
});
{
"confidence": 10,
"id": 882431006,
"instance": [], // Product instance information
"out_of_stock_purchases": true,
"product_id": 882430998,
"product_instance_id": 882431002,
"quantity_on_hand": 300,
"track_inventory": true,
"type": "product_inventory",
"url": "/v1/product_instances/882431006/"
}
// Confidence must be between 1-10.
{
"errors": [
"Product Inventory Update Exception: confidence must be between 1-10."
]
}