Get All Product Data
Fetch all data product by seller email
Endpoint
Base URL
http://localhost:8080
Method and Endpoint
GET /api/sellers/current/stores/{store_id}/products
Headers
Authorization: Bearer access_token
Route Param
store_id
: string (required)
Query Param
page
: string (optional, default 1)
Responses
You will get responses like this:
Pagination
page
: The current pagetotal_item
: Total item in the pagelast_page
: Number of the last page of pagination
200 (success)
Response Body
{
"message": "Fetch All product Successfully",
"result": {
"products": [
{
"name": "example-product-name",
"description": "example-product-desc",
"price": 99.99,
"stock": 150,
"average_rating": 4.5,
"total_sales": 2500,
"product_id": "WH123456",
"category": "Electronics",
"created_at": "2024-05-30T20:13:21.370Z",
"store_name": "TechStore",
"city": "San Francisco",
"images": [
"https://example.com/images/product1.jpg",
"https://example.com/images/product2.jpg"
]
},
{
"name": "example-product-name",
"description": "example-product-desc",
"price": 149.99,
"stock": 200,
"average_rating": 4.7,
"total_sales": 1800,
"product_id": "SW789012",
"category": "Wearables",
"created_at": "2024-05-25T15:45:12.370Z",
"store_name": "GadgetHub",
"city": "New York",
"images": [
"https://example.com/images/product3.jpg",
"https://example.com/images/product4.jpg"
]
}
],
"page": 1,
"total_item": 2,
"last_page": 1
}
}
404 (not found)
If the store
was not found in database
Response Body
{
"error": "store not found"
}
401 (unauthorized)
Response Body
{
"error": "Invalid authorization header"
}
401 (unauthorized - expire token)
Response Body
{
"error": "token is expired: token is expired by 2m19s"
}
500 (server error)
Response Body
{
"error": "Internal server error"
}
500 (server error - failed)
If query to database
get troble while get the products
data
Response Body
{
"error": "failed to get all products"
}