---
title: "Get product by id"
method: GET
path: "/ecommerce/products/{productId}"
tags: ["🛒 Ecommerce"]
---

# Get product by id

`GET /ecommerce/products/{productId}`

## Request

- Base URL: `https://api.freeapi.app/api/v1`
- URL: `https://api.freeapi.app/api/v1/ecommerce/products/{productId}`
- Auth: none declared
- TypeScript: <https://skmtc.dev/hiteshchoudhary-ssesph/apis/freeapi/docs/ecommerce/products/:productId/get.ts> (a function with typed inputs; its response is checked against the schema)

The API retrieves a product based on the provided `productId` passed as a path variable.

This API serves as a means to fetch specific product information from the backend based on a unique identifier.

By passing the `productId` in the URL, the API searches and retrieves the corresponding product details, including attributes such as name, price, description, stock, images and any other relevant information associated with the product.

## Response `200`

Get product by id

- object
  - `data` object
    - `__v` number
    - `_id` string
    - `category` string
    - `createdAt` string
    - `description` string
    - `mainImage` object
      - `_id` string
      - `localPath` string
      - `url` string
    - `name` string
    - `owner` string
    - `price` number
    - `stock` number
    - `subImages` object[]
      - `_id` string
      - `localPath` string
      - `url` string
    - `updatedAt` string
  - `message` string
  - `statusCode` number
  - `success` boolean

---

[API](https://skmtc.dev/hiteshchoudhary-ssesph/apis/freeapi.md) - [All operations](https://skmtc.dev/hiteshchoudhary-ssesph/apis/freeapi/llms.txt) - [OpenAPI document](https://skmtc.dev/hiteshchoudhary-ssesph/apis/freeapi/revisions/a9f3a290e4dc?raw)
