Product Category

Manage product category

List Product Categories

get
​

β€Žhttps://<domain>/<api prefix>/<version>/commerce/product/list/categories/
This API endpoint will return a list of the product category (product-type)
Request
Response
Request
Headers
apikey
required
string
apikey
Authorization
required
string
Bearer access token
Query Parameters
offset
optional
string
​
limit
optional
string
​
Response
200: OK
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
"status_code": 200,
"errors": {},
"data": {
"results": [
{
"id": <category_id>,
"name": "<category_name>",
"status": <status>,
"has_inventory": <has_inventory_boolean>,
"has_recurring": <has_recurring_boolean>,
"has_variants": <has_variants_boolean>,
"has_shippable": <has_shippable_boolean>,
"has_discount": <has_discount_boolean>,
"created": "<created_date>",
"modified": "<modified_date>",
"data": {
"tax": {
"method": "<method_name>",
"method_status": <status>
},
"afl_fees": {
"method": "<method_name>",
"method_status": <status>
},
...
},
"slug": "<slug>"
}
...
],
"count": <list_count>,
"previous": <previous_page_link>,
"next": "<next_page_link>"
}
}

Sample Code

Node

var request = require('request');
var options = {
'method': 'GET',
'url': 'https://<domain>/<api prefix>/<version>/commerce/product/list/categories/',
'headers': {
'apikey': '<apikey>',
'Authorization': 'Bearer <access token>',
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
​

PHP

<?php
​
$curl = curl_init();
​
curl_setopt_array($curl, array(
CURLOPT_URL => "https://<domain>/<api prefix>/<version>/commerce/product/list/categories/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"apikey: <apikey>",
"Authorization: Bearer <access token>",
),
));
​
$response = curl_exec($curl);
​
curl_close($curl);
echo $response;

Create Product Category

Create a Product category (Product - Type).

  • First, Get the list of enabled product type method configuration through the below-provided endpoint.

  • Then Create product type through the post method.

Active Product Type Method Configurations

get
​

β€Žhttps://<domain>/<api prefix>/<version>/commerce/product/get/producttype/methodconf/
This API endpoint will return enabled product type method configurations
Request
Response
Request
Headers
apikey
required
string
apikey
Authorization
required
string
Bearer access token
Response
200: OK
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
"status_code": 200,
"errors": {},
"data": {
"EnabledProductTypeMethodConf": [
{
"method": "<method_name>",
"weight": <weight>,
"title": "<method_title>",
"description": "<method_description>",
"attr_slug": [],
"disabled_status": <status>
},
...
]
}
}

Sample Code

Node

var request = require('request');
var options = {
'method': 'GET',
'url': 'https://<domain>/<api prefix>/<version>/commerce/product/get/producttype/methodconf/',
'headers': {
'apikey': '<apikey>',
'Authorization': 'Bearer <access token>',
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
​

PHP

<?php
​
$curl = curl_init();
​
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/commerce/product/get/producttype/methodconf/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'apikey: <apikey>',
'Authorization: Bearer <access token>',
),
));
​
$response = curl_exec($curl);
​
curl_close($curl);
echo $response;
​

Create Product Type

post
​

β€Žhttps://<domain>/<api prefix>/<version>/commerce/product/create/category/
This API endpoint will create a product type.
Request
Response
Request
Headers
apikey
required
string
apikey
Authorization
required
string
Bearer access token
Body Parameters
name
required
string
Method name
translations
optional
object
name translations for name
method
optional
array
An array of the string contains method names
catalogue_ids
optional
array
An array of integer contains catalogue ids
attr_grp_ids
optional
array
An array of integer contains product attribute group ids, Require at least one group id
Response
200: OK
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
"status_code": 200,
"errors": {},
"data": {}
}

Body Parameters are JSON.stringify, Refer below block for the body parameter structure, and also refer sample code.

{
"name": "<product-type-name>",
"translations": {
"<language_code>": "<name>",
"<language_code>": "<name>",
...
},
"method": [
"<method_name>",
"<method_name>",
...
],
"catalogue_ids": [
<catalogue_id>,
<catalogue_id>,
...
],
"attr_grp_ids": [
<attr_grp_ids>,
<attr_grp_ids>,
...
]
}

Sample Code

Node

var request = require('request');
var options = {
'method': 'POST',
'url': 'https://<domain>/<api prefix>/<version>/commerce/product/create/category/',
'headers': {
'apikey': '<apikey>',
'Authorization': 'Bearer <access token>',
'Content-Type': 'application/json',
},
body: JSON.stringify({"name":"<method-name>","translations":{"<language_code>":"<name>","<language_code>":"<name>"},"method":["<method_name>","<method_name>"],"catalogue_ids":[<id>,<id>],"attr_grp_ids":[<id>,<id>]})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
​

PHP

<?php
​
$curl = curl_init();
​
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/commerce/product/create/category/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"name": "<method_name>",
"translations": {
"<language_code>": "<name>",
"<language_code>": "<name>"
},
"method": [
"<method_name>",
"<method_name>"
],
"catalogue_ids": [
<id>,
<id>
],
"attr_grp_ids": [
<id>,
<id>
]
}',
CURLOPT_HTTPHEADER => array(
'apikey: <apikey>',
'Authorization: Bearer <access token>',
'Content-Type: application/json',
),
));
​
$response = curl_exec($curl);
​
curl_close($curl);
echo $response;
​

Error Responses

Status Code

Error Type

FIeld

Description

400

Validation Error

name

This field is required.

This field may not be blank.

Ensure this field has no more than 250 characters.

400

Validation Error

catalogue_ids

Provided <catalogue_ids> is not a valid catalogue id

Provided <catalogue_ids> does not exist

400

Validation Error

attr_grp_ids

Provide at least one group

Provided <attr_grp_id> is not a valid group id

Provided <attr_grp_id> does not exist

Update Product Category

post
​

β€Žhttps://<domain>/<api prefix>/<version>/commerce/product/update/category/
This API endpoint will update a product category.
Request
Response
Request
Headers
apikey
required
string
apikey
Authorization
required
string
Bearer access token
Body Parameters
ptype
required
integer
Product type id
name
required
string
New or existing name of the product type
attr_grp_ids
optional
array
Replace with a new array of integer or existing group ids, Require at least one attribute group id.
translations
optional
object
name translations for name
method
optional
array
An array of the string contains method names
catalogue_ids
optional
array
An array of integer contains catalogue ids
Response
200: OK
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
"status_code": 200,
"errors": {},
"data": {}
}

Body Parameters are JSON.stringify, Refer below block for the body parameter structure, and also refer sample code.

{
"ptype":<product_typ>,
"name": "<product-type-name>",
"translations": {
"<language_code>": "<name>",
"<language_code>": "<name>",
...
},
"method": [
"<method_name>",
"<method_name>",
...
],
"catalogue_ids": [
<catalogue_id>,
<catalogue_id>,
...
],
"attr_grp_ids": [
<attr_grp_ids>,
<attr_grp_ids>,
...
]
}

Sample Code

Node

var request = require('request');
var options = {
'method': 'POST',
'url': 'https://<domain>/<api prefix>/<version>/commerce/product/update/category/',
'headers': {
'apikey': '<apikey>',
'Authorization': 'Bearer <access token>',
'Content-Type': 'application/json',
},
body: JSON.stringify({"ptype":<product_type_id>,"name":"<name>","attr_grp_ids":[<id>,<id>],"translations":{"<language_code>":"<name>","<language_code>":"<name>"},"method":["<method_name>","<method_name>"],"catalogue_ids":[<id>,<id>]})
​
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
​

PHP

<?php
​
$curl = curl_init();
​
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/commerce/product/update/category/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"ptype":<product_type_id>,
"name":"<name>",
"attr_grp_ids":[
<id>,
<id>
],
"translations": {
"<language_code>":"<name>",
"<language_code>":"<name>"
},
"method": [
<method_name>",
<method_name>"
],
"catalogue_ids": [
<id>,
<id>
]
}',
CURLOPT_HTTPHEADER => array(
'apikey: <apikey>',
'Authorization: Bearer <access token>',
'Content-Type: application/json',
),
));
​
$response = curl_exec($curl);
​
curl_close($curl);
echo $response;

Error Responses

Status Code

Error Type

FIeld

Description

400

Validation Error

ptype

Product Type id is required.

This field may not be blank.

Product Type does not exist.

400

Validation Error

name

This field is required.

This field may not be blank.

Ensure this field has no more than 250 characters.

400

Validation Error

catalogue_ids

Provided <catalogue_ids> is not a valid catalogue id

Provided <catalogue_ids> does not exist

400

Validation Error

attr_grp_ids

Provide at least one group

Provided <attr_grp_id> is not a valid group id

Provided <attr_grp_id> does not exis

Delete Product Category

delete
​

β€Žhttps://<domain>/<api prefix>/<version>/commerce/product/delete/category/?id=<category_id>
This API endpoint will delete a product category
Request
Response
Request
Headers
apikkey
required
string
apikey
Authorization
required
string
Bearer access token
Query Parameters
id
required
string
Product category id
Response
200: OK
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
"status_code": 200,
"errors": {},
"data": {}
}

Sample Code

Node

var request = require('request');
var options = {
'method': 'DELETE',
'url': 'https://<domain>/<api prefix>/<version>/commerce/product/delete/category/?id=<category_id>',
'headers': {
'apikey': '<apikey>',
'Authorization': 'Bearer <access token>',
},
formData: {}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
​

PHP

<?php
​
$curl = curl_init();
​
curl_setopt_array($curl, array(
CURLOPT_URL => "https://<domain>/<api prefix>/<version>/commerce/product/delete/category/?id=<category_id>",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => array(
"apikey: <apikey>",
"Authorization: Bearer <access token>",
),
));
​
$response = curl_exec($curl);
​
curl_close($curl);
echo $response;
​

Error Responses

Status Code

Error Type

FIeld

Description

400

Invalid Input

id

Category id is not valid.

Category does not exist. This field may not be blank Category id is required.

401

Request Failed

​

There are products in this category.you can't delete it

Category can't delete or remove