Skip to content

Fetch Products

Description

This API retrieves a list of products based on various filter parameters such as name, category, RAM size, storage, brand, and search query.

Endpoint

  • URL: /v1/products
  • Method: GET

Query Parameters

ParameterTypeDescription
sortDirectionParamStringSorting direction (ASC or DESC). Default: ASC.
sortFieldParamStringField to sort results by (e.g., NAME,CATEGORY,PRICE,CREATED_AT). Default: NAME.
nameStringFilter products by name.
minPriceNumberFilter products by minimum price.
maxPriceNumberFilter products by maximum price.
availabilityStringFilter products for availability (in_stock, out_of_stock).
categoryStringFilter products by category.
ramSizeStringFilter products by RAM size (e.g., 16GB).
storageStringFilter products by storage capacity.
brandStringFilter products by brand.
ratingNumberFilter products by rating.
newArrivalNumberFilter products added within a specific time frame (e.g., last 30 days).
searchStringGeneral search query for products.(search by name, description and category)
archivedBooleanFilter by archived status. Default: false.

NOTE

By default, archived products are not returned. To fetch archived products, explicitly set archived=true.

Required Headers

json
{
  "X-MerchantApiKey": "MERCHANT_API_KEY",
  "Content-Type": "application/json"
}

Example API Call (Using Fetch)

javascript
fetch("https://api.shopsynch.com/v1/products?sortDirectionParam=ASC&sortFieldParam=NAME&name=SIGNATURE&category=TV&ramSize=16GB&search=Smart", {
  method: "GET",
  headers: {
    "Authorization": "Bearer JWT_TOKEN",
    "X-MerchantApiKey": "MERCHANT_API_KEY",
    "Content-Type": "application/json"
  }
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));

✅ Sample 200 Response (Success)

json
{
    "status": true,
    "message": "All products retrieved",
    "data": {
        "total": 2,
        "totalPages": 1,
        "currentPage": 0,
        "products": [
            {
                "id": "dc87327c-5394-40d1-9691-6953b2a70cd7",
                "name": "Addidas Men Sports Shoes",
                "description": "Luxury Casual Sneakers Mesh Running Shoes",
                "image": "http://lorempixel.com/1366/768/people/",
                "price": "94668.67",
                "newPrice": "49227.71",
                "quantity": 13,
                "category": "Snail",
                "discount": 48.0
            }
        ]
    }
}

❌ Sample 404 Response (Not Found Error)

json
{
  "status": false,
  "message": "Products not found"
}

Next Steps

Build with joy