Inventory API

Mars API for inventory management.

Authentication

On client registration, you will be receive your client Id, client Secret and refreshed access token for different APIs

Access Token can be passed only in header and cannot be passed in the request param.

  • Header name should be Authorization

  • Header value should be Mars-oauthtoken {access_token}

curl https://inventory.marax.ai/api/v1/products
-H "Authorization: Mars-oauthtoken 1000.41d9f2cfbd1b7a8f9e314b7aff7bc2d1.8fcc9810810a216793f385b9dd6e125f"
-H "Content-Type: application/json"

HTTP Methods

Method

Description

GET

Used for retrieving resources.

POST

Used for creating resources and performing resource actions.

PUT

Used for updating resources.

DELETE

Used for deleting resources.

Response

Node Name

Description

code

Mars Inventory error code. This will be zero for a success response and non-zero in case of an error.

message

Message for the invoked API.

resource name

Comprises the invoked API’s Data.

{
"code": 0,
"message": "success",
"products": [
{...},
{...}
]
}

Errors

Status Code

Description

200

Success. The request was successfully completed.

201

Created The request was a success and one or more resources have been created.

400

Bad request The request cannot be performed. Usually because of malformed parameter or missing parameter.

401

Unauthorized (Invalid AuthToken) Request was rejected because of invalid AuthToken.

404

URL Not Found The URL you’ve sent is wrong. It’s possible that the resource you’ve requested has been moved to another URL.

405

Method Not Allowed The requested resource does not support the HTTP method used. For example, requesting List of all customers API with PUT as the HTTP method.

429

Too many requests Too many requests within a certain time frame.

500

Mars inventory server encountered an error which prevents it from fulfilling the request. Although this rarely happens, we recommend you to contact us over email

Pagination

Mars Inventory provides APIs to retrieve lists of contacts, plans and other resources - paginated to 200 items by default. The pagination information will be included in the list API response under the node name page_context.

  • By default first page will be listed. For navigating through pages, use the page parameter.

  • The per_page parameter can be used to set the number of records that you want to receive in response.

$ curl https://inventory.marax.ai/api/v1/products?page=2&per_page=25
{
"code": 0,
"message": "success",
"products": [
{...},
{...}
],
"page_context": {
"page": 2,
"per_page": 25,
"has_more_page": false
}
}

Schema

Details of Mars Inventory schema can be found here

Examples

  1. Add a new product

URL: https://inventory.marax.ai/api/v1/product
Method: POST
Headers:
Authorization: Mars-oauthtoken 1000.41d9f2cfbd1b7a8f9e314b7aff7bc2d1.8fcc9810810a216793f385b9dd6e125f
Content-Type: application/json
Body:
{
"product_id": "a1v2f3r1",
"sku": "ark-s-040002",
"name": "Sample",
"description": "Sample description",
"category": "Sample",
"subcategory": "Sample",
"brand": "Sample Brand",
"variant": {
"color": "green",
"size": "standard",
"depth": 32,
"width": 45,
"height": 56,
"weight": 145,
"model": "y",
},
"base_price": 26245,
"sale_price": 24789,
"list_price":24738,
"discount_margin": 10,
"profit_margin": 30,
"discount": 1500,
"currency": "INR",
"url": "https://url-to-your-product",
"image_url": "https://url_to_product_image",
"seller": "sample seller",
"rating": 3.5,
"stock":120,
"tags": ["foldable"],
"published": true,
"user_quantity_limit": 2
}
Response:
{
"code": 0,
"message": "success",
"product": {
"product_id": "a1v2f3r1",
...
}
}

2. Get All products

URL: https://inventory.marax.ai/api/v1/products?page=1&per_page=25
Method: GET
Headers:
Authorization: Mars-oauthtoken 1000.41d9f2cfbd1b7a8f9e314b7aff7bc2d1.8fcc9810810a216793f385b9dd6e125f
Content-Type: application/json
Response:
{
"code": 0,
"message": "success",
"products": [
{...},
{...}
],
"page_context": {
"page": 1,
"per_page": 25,
"has_more_page": false
}
}

3. Get a product

URL: https://inventory.marax.ai/api/v1/product?product_id=a1huwhqyt2
Method: GET
Headers:
Authorization: Mars-oauthtoken 1000.41d9f2cfbd1b7a8f9e314b7aff7bc2d1.8fcc9810810a216793f385b9dd6e125f
Content-Type: application/json
Response:
{
"code": 0,
"message": "success",
"product": {
"product_id": "a1huwhqyt2",
...
}
}

4. Update a product

URL: https://inventory.marax.ai/api/v1/product
Method: PUT
Headers:
Authorization: Mars-oauthtoken 1000.41d9f2cfbd1b7a8f9e314b7aff7bc2d1.8fcc9810810a216793f385b9dd6e125f
Content-Type: application/json
Body:
{
"product_id": "a1v2f3r1",
"sku": "ark-s-040002",
"name": "Sample",
"description": "Sample description",
"category": "Sample",
"subcategory": "Sample",
"brand": "Sample Brand",
"variant": {
"color": "green",
"size": "standard",
"depth": 32,
"width": 45,
"height": 56,
"weight": 145,
"model": "y",
},
"base_price": 26245,
"sale_price": 24789,
"list_price":24738,
"discount_margin": 10,
"profit_margin": 30,
"discount": 1500,
"currency": "INR",
"url": "https://url-to-your-product",
"image_url": "https://url_to_product_image",
"seller": "sample seller",
"rating": 3.5,
"stock":120,
"tags": ["foldable"],
"published": true,
"user_quantity_limit": 2
}
Response:
{
"code": 0,
"message": "success",
"product": {
"product_id": "a1v2f3r1",
...
}
}