Fetch all products

GET /products

Use this endpoint to retrieve the details of all the products you created. In this example, count and skip query parameters have been used. You can invoke this API without these query parameters as well.

Header

                    
                        Authorization
                        Example: Bearer {YOUR_AUTH_KEY}
                        Content-Type
                        Example: application/json
                        Accept
                        Example: application/json
                    
                

Query Parameters

Parameter Datatype Description
product_name string(optional) Retrieves the products that contain the provided value for product_name.
from_date string (optional) Format dd-mm-yyyy
to_date string (optional) Format dd-mm-yyyy
count integer(optional) The number of orders to be fetched. The default value is 10. The maximum value is 100. This can be used for pagination, in combination with skip.
skip integer(optional) The number of orders to be skipped. The default value is 0. This can be used for pagination, in combination with count.

Response Parameters

Parameter Datatype Description
id integer The unique identifier of the product.
name string The name of the product.
image string (URL) The URL of the product image.
sku string The SKU of the product and this also a unique identifier of the product.
hsn_code string The HSN code of the product.
description string The description of the product.
price_per_unit double Price of the per unit product.
maximum_retail_price double MRP of the product.
weight double Per unit weight of the product.
vol double Per unit volume of the product.
gst_percent double GST percentage of the product.
measurementtype collection Collection of product measurement type.
measurementtype.id integer The unique identifier of the product measurement type.
measurementtype.name string The name of the product measurement type.
productcategory collection Collection of product categories.
productcategory.id integer The unique identifier of the product category.
productcategory.name string The name of the product category.
productcategory.image string (URL) The URL of the product category image.
productpricings collection Collection of product pricings.
productpricings.id integer Unique identifier or id of the product pricing or pricing set. Product pricings are pricing sets setup for specific buying quantities of the same product. Example - Tata Tea Gold is the product and Pack of 12, Pack of 18 or Pack of 24 are 3 product pricing sets of the product.
productpricings.product_id integer ID of the product.
productpricings.buying_qty integer Product Pricings are basically selling prices for a specific set of quantity or pricing set. Here buying_qty refers to the qty against the pricing set .
productpricings.price double Selling price of the specific product pricing or pricing set against the specific buying quantity .
pagination Collection of pagination settings. These settings are used to limit the amount of data retrieved in each request.
pagination.current_page integer This is basically the current page number
pagination.first_page_url string (URL) Data loaded form this page url.
pagination.prev_page_url string (URL) This is the previous page URL of the current page URL
pagination.next_page_url string (URL) This is the next page URL of the current page URL
pagination.last_page_url string (URL) This is the last page where data exists.
pagination.last_page integer The number of last page.
pagination.per_page integer The number of data loaded in a page.
pagination.total integer Total number of row (Data) exists.
pagination.path integer Full path of the api.

Sample Request

                    
                        curl --location 'https://webservices.sourcehub.in/api/products?count=10&skip=0&product_name=null' \
                        --header 'Authorization: Bearer *************'
                    
                

Sample Success Response

                    
                        {
                            "data": {
                                "products": [
                                    {
                                        "id": 1,
                                        "name": "XRed label 100gms Mrp 40",
                                        "image": "https://sourcehub.in/public/images/product/1605339316.jpg",
                                        "sku": "SH000064",
                                        "hsn_code": "0902",
                                        "description": '',
                                        "price_per_unit": 40,
                                        "maximum_retail_price": 50,
                                        "weight": 100,
                                        "vol": 0,
                                        "gst_percent": 5,
                                        "measurementtype": {
                                            "id": 2,
                                            "name": "Pcs"
                                        },
                                        "productcategory": {
                                            "id": 3,
                                            "name": "Tea ,Coffee and Beverages",
                                            "image": "https://sourcehub.in/public/images/productcategory/1617180572.jpg"
                                        },
                                        "productpricings": [
                                            {
                                                "id": 1,
                                                "product_id": 1,
                                                "buying_qty": 0,
                                                "price": 0
                                            },
                                            {
                                                "id": 1049,
                                                "product_id": 1,
                                                "buying_qty": 1,
                                                "price": 100
                                            }
                                        ]
                                    },
                                    {
                                        "id": 4,
                                        "name": "3 Roses Mrp 10 (408pc)",
                                        "image": "https://sourcehub.in/public/images/product/1605342130.jpg",
                                        "sku": "CP 2425 0046",
                                        "hsn_code": "0902",
                                        "description": '',
                                        "price_per_unit": 10,
                                        "maximum_retail_price": 4080,
                                        "weight": 3000,
                                        "vol": 0,
                                        "gst_percent": 5,
                                        "measurementtype": {
                                            "id": 5,
                                            "name": "bags"
                                        },
                                        "productcategory": {
                                            "id": 3,
                                            "name": "Tea ,Coffee and Beverages",
                                            "image": "https://sourcehub.in/public/images/productcategory/1617180572.jpg"
                                        },
                                        "productpricings": [
                                            {
                                                "id": 1058,
                                                "product_id": 4,
                                                "buying_qty": 1,
                                                "price": 200
                                            },
                                            {
                                                "id": 244,
                                                "product_id": 4,
                                                "buying_qty": 1,
                                                "price": 3430
                                            },
                                            {
                                                "id": 1539,
                                                "product_id": 4,
                                                "buying_qty": 1,
                                                "price": 3502
                                            }
                                        ]
                                    }
                                ],
                                "pagination": {
                                    "current_page": 1,
                                    "first_page_url": "http://testwebservices.sourcehub.in/api/products?page=1",
                                    "prev_page_url": null,
                                    "next_page_url": "http://testwebservices.sourcehub.in/api/products?page=2",
                                    "last_page_url": "http://testwebservices.sourcehub.in/api/products?page=12",
                                    "last_page": 12,
                                    "per_page": 2,
                                    "total": 35,
                                    "path": "http://testwebservices.sourcehub.in/api/products"
                                }
                            }
                        }
                    
                

Sample 401 Faliure Response

                    
                        {
                            "error": {
                                "code": "AUTHENTICATION_ERROR",
                                "description": "Invalid credential or token.",
                                "source": "https://webservices.sourcehub.in/api/products",
                                "status_code": 401
                            }
                        }
                    
                

Errors

The API key/secret provided is invalid. Error Status: 401

The API credentials passed in the API call differ from the ones generated on the Dashboard. Possible reasons are:

  • Different keys for test mode and live modes.
  • Expired API key.

Solution :
The API keys must be active and entered correctly with no whitespace before or after the keys.

CONTENTS