Chuyển tới nội dung chính

Danh sách kho

1. Thông tin API

  • Endpoint: /api/v6.1/warehouses
  • Method: GET
  • Mô tả: Lấy danh sách kho đang hoạt động (valid = 1). Lọc, sắp xếp, phân trang và fields tuân theo Thông tin cần thiết và domain public API Warehouse.
HeaderBắt buộcMô tả
X-API-KEYAPI key do CRM cấp
Content-TypeKhuyến nghịapplication/json (đồng bộ với Giới thiệu)

2. Tham số Request

2.1. Filtering (Lọc dữ liệu)

TrườngHỗ trợKiểu dữ liệuMô tả
ideq, inintegerID kho (store_id)
validis, inintegerTrạng thái hiệu lực (API public luôn ép valid = 1 nếu không truyền)
storekeepereq, inintegerThủ kho
inventory_in_request_usereqintegerUser yêu cầu nhập kho
inventory_out_request_usereqintegerUser yêu cầu xuất kho
inventory_request_usereqintegerUser yêu cầu kho
product_ideqintegerLọc theo ID sản phẩm (cấu hình domain)
product_nameeq, containsstringTên sản phẩm
product_codeeq, containsstringMã sản phẩm
product_category_ideq, inintegerDanh mục sản phẩm
product_unit_ideqintegerĐơn vị tính
(và các trường product_* khác trong domain)Theo domainMở rộng theo cấu hình sản phẩm + custom fields module sản phẩm

Ngoài ra có thể lọc lồng sub_account (khách hàng) tương tự các API CRM khác khi domain hỗ trợ — tham chiếu backend domain Warehouse::handleConditions.

  • Tham số: search (chuỗi tìm kiếm).
  • Phạm vi mặc định (domain): store_name, store_code.

2.3. Sorting (Sắp xếp)

TrườngHướng
idasc, desc

Mặc định: sort=id, direction=desc (theo domain).

2.4. Fields — trường được phép trên Public API v6.1

Public API chỉ cho phép truy xuất tập tối thiểu sau (truyền fields dạng CSV, ví dụ fields=id,store_name,total_quantity):

TrườngKiểuMô tả
idintegerID kho
store_namestringTên kho
total_quantitynumberTổng tồn (tổng hợp theo cấu hình hệ thống)

Nếu không gửi fields, hệ thống mặc định chỉ trả id.

2.5. Pagination (Phân trang)

Tham sốKiểu dữ liệuMô tả
limitintegerSố bản ghi tối đa mỗi lần gọi
offsetintegerSố bản ghi bỏ qua từ đầu danh sách

Giới hạn limit có thể bị chặn theo cấu hình chung Public API (class service kế thừa BasePublicAPIApplicationService).


3. Response mẫu

{
"data": [
{
"id": 1,
"store_name": "Kho chính",
"total_quantity": 15240.5
}
],
"has_more": false,
"offset": 0,
"limited": 50,
"sorted": { "id": "DESC" }
}

(Các khóa envelope như has_more, limited, sorted có thể đầy đủ hơn tùy phiên bản CRM — luôn đối chiếu response thực tế.)


4. Mô tả các trường dữ liệu (bản ghi kho)

TrườngKiểuMô tả
idintegerĐịnh danh kho
store_namestringTên hiển thị kho
total_quantitynumberTổng số lượng tồn tổng hợp (theo logic CRM)

5. Ghi chú

  • URL có ký tự filtering[...]: trên shell nên bọc URL trong nháy đơn hoặc dùng curl -g để [ ] không bị glob.
  • Tồn kho theo sản phẩm (theo API product/...) xem Tồn kho sản phẩm.

Ví dụ curl

curl --location 'https://example.getflycrm.com/api/v6.1/warehouses?fields=id,store_name,total_quantity&limit=50&sort=id&direction=desc' \
--header 'X-API-KEY: <your_api_key>'