get /shops/{SHOP_ID}/inventory_histories
GET/shops/{SHOP_ID}/inventory_historiesGọi qua 360: GET https://partner.quantri360.com/v1/pancake_pos/shops/{SHOP_ID}/inventory_histories
Sắp mở. API này đã chạy thật qua 360 và đang được chốt giá — bạn có thể đọc tài liệu và chuẩn bị tích hợp trước.
Mô tả API
Lịch sử xuất nhập kho từng dòng: mẫu mã nào, kho nào, tăng / giảm bao nhiêu, do việc gì (thêm vào đơn, nhập Excel, phiếu nhập, chuyển kho…), tồn sau thay đổi, ai làm. Dùng để truy vết chênh lệch tồn và dựng thẻ kho.
- startDate / endDate là Unix GIÂY (gửi mili giây cũng ra cùng kết quả). Gọi thật: dòng
inserted_at2026-08-31T09:43 lọc khớp khi khoảng là 09:30–10:00 UTC, KHÔNG khớp 09:30–10:00 giờ VN →inserted_atlà UTC, cộng 7 giờ ra giờ VN. idcó thể là số rất lớn (vd 276701174445076700) — JSON.parse của JavaScript làm tròn mất chữ số cuối; đọc bằng bộ parse giữ số lớn nếu cần dùng id.- Có tên, email, SĐT nhân viên trong
user.
Request
Địa chỉ
GET https://partner.quantri360.com/v1/pancake_pos/shops/{SHOP_ID}/inventory_histories
Xác thực & gian hàng
| Tên | Vị trí | Kiểu | Mẫu | Mô tả |
|---|---|---|---|---|
| Authorization | header | header | Bearer q360_live_ab12cd34_… | Khóa API của brand (tạo ở mục API key). Bắt buộc với mọi request. Brand suy từ key — không truyền mã brand. |
| platform_shop_id | query | string | 1234567 | SHOP_ID đã nối — có thể bỏ khi đường dẫn có /shops/{SHOP_ID}. |
Tham số request
| Tên | Vị trí | Kiểu | Bắt buộc | Mẫu | Mô tả |
|---|---|---|---|---|---|
| SHOP_ID | path | integer | Có | 1234567 | Mã cửa hàng đã nối với 360. |
| page | query | int | Có | 1 | Trang, từ 1. |
| page_size | query | int | Có | 100 | Số dòng / trang — gọi thật 1000 vẫn nhận. |
| warehouse_id | query | string | Không | 6d1b3245-… | Lọc một kho. |
| variation_ids[] | query | string[] | Không | f40a94fe-… | Lọc mẫu mã; lặp tham số cho nhiều mã. |
| startDate | query | int | Không | 1788109200 | Từ (Unix giây). |
| endDate | query | int | Không | 1788195599 | Đến (Unix giây). |
Phân trang
Tăng page tới total_pages. Mới nhất trước.
Ví dụ request
curl -s "https://partner.quantri360.com/v1/pancake_pos/shops/1234567/inventory_histories?page=1&page_size=100&startDate=1788109200&endDate=1788195599" \ -H "Authorization: Bearer $KEY"
Python
import requests
KEY = "q360_live_..." # khóa API của brand
r = requests.get(
"https://partner.quantri360.com/v1/pancake_pos/shops/1234567/inventory_histories",
params={
"page": 1,
"page_size": 100,
"startDate": 1788109200,
"endDate": 1788195599
},
headers={"Authorization": f"Bearer {KEY}"},
timeout=60,
)
print(r.status_code)
print(r.json())Node.js
const KEY = 'q360_live_...'; // khóa API của brand
const url = new URL('https://partner.quantri360.com/v1/pancake_pos/shops/1234567/inventory_histories');
for (const [k, v] of Object.entries({"page":1,"page_size":100,"startDate":1788109200,"endDate":1788195599})) url.searchParams.set(k, typeof v === 'object' ? JSON.stringify(v) : String(v));
const r = await fetch(url, {
method: 'GET',
headers: { Authorization: `Bearer ${KEY}` },
});
console.log(r.status, await r.json());PHP
<?php $key = 'q360_live_...'; // khóa API của brand $url = 'https://partner.quantri360.com/v1/pancake_pos/shops/1234567/inventory_histories' . '?' . http_build_query(['page' => 1, 'page_size' => 100, 'startDate' => 1788109200, 'endDate' => 1788195599]); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer ' . $key]); $res = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); echo $status, "\n", $res;
Response
Tham số phản hồi (nguyên của Pancake POS)
| Tên | Kiểu | Mẫu | Mô tả |
|---|---|---|---|
| success | bool | true | |
| data | object[] | Dòng biến động. | |
| id | int | 8751077740 | Mã dòng — CÓ THỂ VƯỢT 2^53 (xem ghi chú). |
| type | string | Thêm sản phẩm vào đơn hàng #9700 | Mô tả việc gây biến động (chữ, có số đơn / phiếu). |
| table_name | string | orders | Nguồn: `orders` · `purchases` · … |
| record_id | string | Mã bản ghi nguồn. | |
| ref_display_id | string | 9700 | Số đơn / phiếu hiển thị. |
| quantity | int | -1 | Thay đổi (âm = xuất, dương = nhập). |
| remain_quantity | int | 7 | Tồn bán được sau thay đổi. |
| avg_price | number | 0 | Giá vốn bình quân. |
| warehouse | object | id, name, full_address, phone_number. | |
| variation | object | name, fields. | |
| variation_now | object | Mẫu mã hiện tại: id, display_id, barcode, retail_price, product_id… | |
| current_inventory | object[] | Tồn hiện tại theo kho: id, name, remain_quantity, actual_remain_quantity, total_quantity, avg_price. | |
| inserted_at | string | 2026-08-31T09:43:32.247330 | Thời điểm — UTC (không có Z). |
| user | object | Người thao tác: id, name, email, phone_number. | |
| editor_id | string | ||
| note_type | int | 6 | |
| page_number / page_size / total_pages / total_entries | int |
Mẫu phản hồi
{
"success": true,
"data": [
{
"id": 8751077740,
"type": "Thêm sản phẩm vào đơn hàng #9700",
"table_name": "orders",
"record_id": "270229060048132",
"ref_display_id": "9700",
"quantity": -1,
"remain_quantity": 7,
"avg_price": 0,
"inserted_at": "2026-08-31T09:43:32.247330",
"note_type": 6,
"user": {
"id": "0744b189-…",
"name": "Nhân viên B",
"email": "nhanvienb@example.com"
},
"warehouse": {
"id": "6d1b3245-…",
"name": "Kho tổng HN"
},
"variation": {
"name": "Đầm xòe phối ren/M",
"fields": []
},
"variation_now": {
"id": "f40a94fe-…",
"display_id": "SDPBC2075-M",
"barcode": "17530000",
"retail_price": 1189000
},
"current_inventory": [
{
"id": "6d1b3245-…",
"name": "Kho tổng HN",
"remain_quantity": 7,
"actual_remain_quantity": 8,
"total_quantity": 8,
"avg_price": 0
}
]
}
],
"page_size": 100,
"total_pages": 93,
"page_number": 1,
"total_entries": 9253
}
Bắt đầu dùng
- Đăng ký tài khoản Partner
- Mở loại dữ liệu thuộc nhóm Kho ở trang nền tảng
- Tạo API key (tick kênh Pancake POS)
- Gọi theo ví dụ ở trên