Fetch a Product Stock History With ID
| GET | products/{id}/stock-history |
|---|
You can use this endpoint to access the stock history of a specific product. In the example provided, we demonstrate how to utilize the count and skip query parameters to customize your request. However, it's important to note that you can also invoke this API without including these parameters.
Header
Authorization
Example: Bearer {YOUR_AUTH_KEY}
Content-Type
Example: application/json
Accept
Example: application/json
URL Parameters
| Parameter | Datatype | Description |
|---|---|---|
| id | integer(required) | This is a product ID |
Query Parameters
| Parameter | Datatype | Description |
|---|---|---|
| from_date | string (optional) | Format dd-mm-yyyy |
| to_date | string (optional) | Format dd-mm-yyyy |
| count | integer(optional) | The number of stock to retrieve is set to a default value of 10, with a maximum limit of 100. This parameter can be utilized for pagination in conjunction with the 'skip' option. |
| skip | integer(optional) | The number of stocks to skip, with a default value of 0. This parameter can be utilized for pagination in conjunction with the count. |
Response Parameters
| Parameter | Datatype | Description |
|---|---|---|
| data | object | This object contains the entire resource. |
| stock_history | object | This object contains the stock history related resource. |
| date_time | string | History created date time. |
| quantity | integer | Effected quantity of history creation. |
| closing_stock | integer | last stock quantity of history creation. |
| description | string | Description of the history creation. |
| 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/100/stock-history?skip=0&count=10' \
--header 'Authorization: Bearer **************'
Sample Success Response
{
"data": {
"stock_history": [
{
"date_time": "20-01-2024 11:47:39",
"quantity": -720,
"closing_stock": 0,
"description": "Product removed by Caterpure Mob"
},
{
"date_time": "16-06-2023 12:28",
"quantity": 12,
"closing_stock": 720,
"description": "Product returned"
},
{
"date_time": "12-06-2023 21:28",
"quantity": -12,
"closing_stock": 708,
"description": "New Order"
},
{
"date_time": "18-04-2023 18:44",
"quantity": 720,
"closing_stock": 720,
"description": "Product added by Karthik Vecham"
}
],
"pagination": {
"current_page": 1,
"first_page_url": "https://webservices.sourcehub.in/api/products/100/stock-history?page=1",
"prev_page_url": null,
"next_page_url": null,
"last_page_url": "https://webservices.sourcehub.in/api/products/100/stock-history?page=1",
"last_page": 1,
"per_page": 10,
"total": 4,
"path": "https://webservices.sourcehub.in/api/products/100/stock-history"
}
}
}
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.