Skip to main content

Retrieve Products

GET /api/v1/products

Description

Retrieves a comprehensive list of products, allowing for detailed analysis based on search terms, stock levels, product types, and other filtering criteria. This endpoint supports extensive filtering and sorting to provide tailored insights into inventory and product offerings.

Headers:

  • tenantId (required): The tenant ID under which the products are registered. This should be included as a header.
  • userId (required): The user ID of the individual requesting the product information. This should also be included as a header.
  • countryCode (required): The country code where the products are registered or sold. This should be included as a header.

Query Parameters:

  • productSearch (optional): A general search term to filter the products.
  • productDateRange (optional): Filters the products by a specific date range. Format: start_date,end_date (e.g., 2020-11-12,2022-11-15).
  • productLowStock (optional): A threshold to filter products with low stock levels.
  • productQuantity (optional): Filters products by quantity available.
  • productByProductTypeIds (optional): Filters products based on product type IDs.
  • productIds (optional): Filters products based on specific product IDs.
  • productActive (optional): Filters products based on active status. Available values: 0 (inactive), 1 (active).
  • byStates (optional): Filters products by states.
  • byCities (optional): Filters products by cities.
  • byBusinessIds (optional): Filters products by business IDs.
  • order (optional): Specifies the order of the results. Available values: ASC, DESC.
  • page (optional): Specifies the pagination page.
  • limit (optional): Specifies the number of results per page.

Example Request:

curl -G "http://[base_url]/api/v1/products" \
-H "Authorization: Bearer [access_token]" \
-H "tenantId: TEN123" \
-H "userId: USR456" \
-H "countryCode: US" \
-d "productSearch=apple" \
-d "productDateRange=2020-11-12,2022-11-15" \
-d "productLowStock=10" \
-d "productQuantity=50" \
-d "productByProductTypeIds=123,124" \
-d "productIds=1001,1002" \
-d "productActive=1" \
-d "byStates=California" \
-d "byCities=San Francisco" \
-d "byBusinessIds=BIZ123" \
-d "order=ASC" \
-d "page=1" \
-d "limit=10"

Responses:

  • 200 OK: Successfully retrieved the list of products. The response includes detailed information about each product that matches the filter criteria.

Example Response:

{
"products": [
{
"productId": "1001",
"name": "Organic Apple",
"description": "Fresh organic apples from sustainable orchards.",
"quantity": 50,
"costPrice": 0.50,
"sellingPrice": 1.00,
"currencyCode": "USD",
"isActive": true,
"businessId": "BIZ123",
"productTypeId": "123",
"stockLevel": "Low",
"photoUrl": "http://example.com/photo1.jpg"
}
],
"totalItems": 100,
"totalPages": 10,
"currentPage": 1
}

Error Responses:

  • 400 Bad Request: Incorrect or incomplete query parameters.
  • 404 Not Found: No products found based on the provided criteria.
  • 403 Forbidden: The user does not have permission to view the product details.

LANGUAGE

AUTHORIZATION

Bearer

CURL REQUEST


curl --request GET \ 
--url /api/v1/products \
--header 'accept: application/json' \
--header 'content-type: application/json'

RESPONSE


Click Try It! to start a request and see the response here!