Product API
Manage a store's catalog using product and catalog APIs
What's a product?
Really? Did you already forget what you are here for? C'mon~Get on with it. Add them to the system and let's get to work.
Product Entity
{
"id":"ac1d0002-7487-1871-8174-9b1a71c75e37"
"category":
{
"id":"c0a8c002-7455-1991-8174-553b9968000b"
"title":"Z Category"
}
"skuId":"srr34545"
"title":"Roobak"
"description":""
"taxable":true
"stock":3
"available":true
"weight":0
"weightUnit":"kg"
"tags":["new", "hot"]
"images":[]
"attributes":[]
"price":[]
"tax":[]
}
Creating a product
Let's just hope you kept that category id from the last page. Else you might wanna go fetch it using the List Categories API.
If you have the category id, we can now start adding products to this category. Here we are passing only the bare minimum data title
, description
and stock
to create the product.
See our Create Product reference section to view all the relevant fields needed to add a product.
curl --request POST \
--url https://ecom.api.zoko.io/v1/product \
--header 'apikey: your-api-key-here' \
--header 'content-type: application/json' \
--data '{"category":{"id":"75df5ab8-f1fa-11ea-9b75-42010a67e00f"},"title":"Chess Board","description":"Medium Size Chess Board","stock":40}'
const request = require('request');
const options = {
method: 'POST',
url: 'https://ecom.api.zoko.io/v1/product',
headers: {apikey: 'your-api-key-here', 'content-type': 'application/json'},
body: {
category: {id: '75df5ab8-f1fa-11ea-9b75-42010a67e00f'},
title: 'Chess Board',
description: 'Medium Size Chess Board',
stock: 40
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
import requests
url = "https://ecom.api.zoko.io/v1/product"
payload = {
"category": {"id": "75df5ab8-f1fa-11ea-9b75-42010a67e00f"},
"title": "Chess Board",
"description": "Medium Size Chess Board",
"stock": 40
}
headers = {"content-type": "application/json"}
response = requests.request("POST", url, json=payload, headers=headers)
print(response.json())
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://ecom.api.zoko.io/v1/product")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["apikey"] = 'your-api-key-here'
request["content-type"] = 'application/json'
request.body = "{\"category\":{\"id\":\"75df5ab8-f1fa-11ea-9b75-42010a67e00f\"},\"title\":\"Chess Board\",\"description\":\"Medium Size Chess Board\",\"stock\":40}"
response = http.request(request)
puts response.read_body
Response
{
"id": "068a169a-f1fe-11ea-9b75-42010a67e00f",
"type": "Product",
"action": "created"
}
Fetching product details
We can now use the Get Product endpoint to see the newly created products in your store.
Please refer and try out the API at Get Product reference section
curl --request GET \
--url https://ecom.api.zoko.io/v1/product/068a169a-f1fe-11ea-9b75-42010a67e00f \
--header 'apikey: your-api-key-here'
import requests
url = "https://ecom.api.zoko.io/v1/product/068a169a-f1fe-11ea-9b75-42010a67e00f"
headers = {"apikey": "your-api-key-here"}
response = requests.request("GET", url, headers=headers)
print(response.text)
const request = require('request');
const options = {
method: 'GET',
url: 'https://ecom.api.zoko.io/v1/product/068a169a-f1fe-11ea-9b75-42010a67e00f',
headers: {apikey: 'your-api-key-here'}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://ecom.api.zoko.io/v1/product/068a169a-f1fe-11ea-9b75-42010a67e00f")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["apikey"] = 'your-api-key-here'
response = http.request(request)
puts response.read_body
Response
{
"id": "068a169a-f1fe-11ea-9b75-42010a67e00f",
"category": {
"id": "75df5ab8-f1fa-11ea-9b75-42010a67e00f",
"title": "Category Title"
},
"skuId": "",
"title": "Chess Board",
"description": "Medium Size Chess Board",
"priceIncludesTax": true,
"stock": 40,
"weight": 0,
"weightUnit": "",
"tags": null,
"images": [],
"attributes": [],
"price": [],
"tax": []
}
Next Step: Now let's try out Order API
Updated over 1 year ago