API Products - Hướng dẫn sử dụng
API Products - Hướng dẫn sử dụng
Tổng quan
API Products v2 cung cấp các endpoint RESTful để quản lý sản phẩm một cách toàn diện, bao gồm CRUD operations, upload hình ảnh, và các tính năng tìm kiếm nâng cao.
Base URL và Authentication
Base URL
https://your-domain.com/api/v2/productsAuthentication
API yêu cầu xác thực thông qua Bearer token:
Authorization: Bearer YOUR_API_TOKENCác endpoint chính
1. Lấy danh sách sản phẩm
Endpoint: GET /api/v2/products
Lấy danh sách sản phẩm với phân trang và bộ lọc.
Query Parameters
| Tham số | Kiểu | Bắt buộc | Mô tả |
|---|---|---|---|
page | Integer | Không | Số trang (mặc định: 1) |
limit | Integer | Không | Số lượng sản phẩm mỗi trang (mặc định: 10, tối đa: 100) |
search | String | Không | Tìm kiếm theo tên, barcode, mô tả |
category | String | Không | Lọc theo danh mục |
min_price | Number | Không | Giá tối thiểu |
max_price | Number | Không | Giá tối đa |
sort_by | String | Không | Sắp xếp theo trường (mặc định: created_at) |
sort_order | String | Không | Thứ tự sắp xếp ASC/DESC (mặc định: DESC) |
Ví dụ sử dụng
curl -X GET "https://your-domain.com/api/v2/products?page=1&limit=20&search=điện thoại&category=Điện tử" \
-H "Authorization: Bearer YOUR_API_TOKEN"Cấu hình HTTP Request Node:
- URL:
https://your-domain.com/api/v2/products - Method:
GET - Query Parameters:
page: 1 limit: 20 search: điện thoại category: Điện tử - Headers:
Authorization: Bearer YOUR_API_TOKEN
function getProducts($token, $params = []) {
$url = 'https://your-domain.com/api/v2/products?' . http_build_query($params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Sử dụng
$params = [
'page' => 1,
'limit' => 20,
'search' => 'điện thoại',
'category' => 'Điện tử'
];
$result = getProducts('YOUR_API_TOKEN', $params);import requests
def get_products(token, params=None):
url = 'https://your-domain.com/api/v2/products'
headers = {'Authorization': f'Bearer {token}'}
response = requests.get(url, headers=headers, params=params)
return response.json()
# Sử dụng
params = {
'page': 1,
'limit': 20,
'search': 'điện thoại',
'category': 'Điện tử'
}
result = get_products('YOUR_API_TOKEN', params)Response
{
"status": "success",
"data": [
{
"id": 1,
"barcode": "SP001",
"main_barcode": "SP001",
"name": "Sản phẩm mẫu",
"list_price": 100000,
"price": 80000,
"description": "Mô tả sản phẩm",
"categories": ["Điện tử", "Công nghệ"],
"attributes": {
"Màu sắc": "Đen",
"Kích thước": "M"
},
"images": [
"https://domain.com/public/uploads/products/1/image1.jpg"
],
"allow_post": true,
"apiget": 5,
"created_at": "2024-01-01 10:00:00",
"updated_at": "2024-01-01 10:00:00"
}
],
"pagination": {
"current_page": 1,
"per_page": 10,
"total": 50,
"total_pages": 5
}
}2. Lấy thông tin chi tiết sản phẩm
Theo ID
Endpoint: GET /api/v2/products/{id}
Theo Barcode
Endpoint: GET /api/v2/products/barcode/{barcode}
# Theo ID
curl -X GET "https://your-domain.com/api/v2/products/1" \
-H "Authorization: Bearer YOUR_API_TOKEN"
# Theo Barcode
curl -X GET "https://your-domain.com/api/v2/products/barcode/SP001" \
-H "Authorization: Bearer YOUR_API_TOKEN"Cấu hình HTTP Request Node:
- URL:
https://your-domain.com/api/v2/products/1(hoặc/barcode/SP001) - Method:
GET - Headers:
Authorization: Bearer YOUR_API_TOKEN
function getProductById($id, $token) {
$url = "https://your-domain.com/api/v2/products/{$id}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Sử dụng
$product = getProductById(1, 'YOUR_API_TOKEN');import requests
def get_product_by_id(product_id, token):
url = f'https://your-domain.com/api/v2/products/{product_id}'
headers = {'Authorization': f'Bearer {token}'}
response = requests.get(url, headers=headers)
return response.json()
# Sử dụng
product = get_product_by_id(1, 'YOUR_API_TOKEN')Response
{
"status": "success",
"data": {
"id": 1,
"barcode": "SP001",
"main_barcode": "SP001",
"name": "Sản phẩm mẫu",
"list_price": 100000,
"price": 80000,
"description": "Mô tả sản phẩm",
"categories": ["Điện tử", "Công nghệ"],
"attributes": {
"Màu sắc": "Đen",
"Kích thước": "M"
},
"images": [
"https://domain.com/public/uploads/products/1/image1.jpg"
],
"allow_post": true,
"apiget": 5,
"created_at": "2024-01-01 10:00:00",
"updated_at": "2024-01-01 10:00:00"
}
}3. Tạo sản phẩm mới
Endpoint: POST /api/v2/products
Request Body
{
"barcode": "SP002",
"main_barcode": "SP002",
"name": "Sản phẩm mới",
"list_price": 150000,
"price": 120000,
"description": "Mô tả sản phẩm mới",
"categories": ["Điện tử", "Công nghệ"],
"attributes": {
"Màu sắc": "Trắng",
"Kích thước": "L"
},
"images": [
"https://example.com/image1.jpg",
"https://example.com/image2.jpg"
],
"allow_post": true
}curl -X POST "https://your-domain.com/api/v2/products" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"barcode": "SP002",
"name": "Sản phẩm mới",
"list_price": 150000,
"price": 120000,
"description": "Mô tả sản phẩm mới",
"categories": ["Điện tử"],
"allow_post": true
}'Cấu hình HTTP Request Node:
- URL:
https://your-domain.com/api/v2/products - Method:
POST - Send Body:
true - Body Type:
JSON - Headers:
Authorization: Bearer YOUR_API_TOKEN Content-Type: application/json - Body (JSON):
{ "barcode": "SP002", "name": "Sản phẩm mới", "list_price": 150000, "price": 120000, "description": "Mô tả sản phẩm mới", "categories": ["Điện tử"], "allow_post": true }
function createProduct($data, $token) {
$url = 'https://your-domain.com/api/v2/products';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token,
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Sử dụng
$data = [
'barcode' => 'SP002',
'name' => 'Sản phẩm mới',
'list_price' => 150000,
'price' => 120000,
'description' => 'Mô tả sản phẩm mới',
'categories' => ['Điện tử'],
'allow_post' => true
];
$result = createProduct($data, 'YOUR_API_TOKEN');import requests
import json
def create_product(data, token):
url = 'https://your-domain.com/api/v2/products'
headers = {
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers, data=json.dumps(data))
return response.json()
# Sử dụng
data = {
'barcode': 'SP002',
'name': 'Sản phẩm mới',
'list_price': 150000,
'price': 120000,
'description': 'Mô tả sản phẩm mới',
'categories': ['Điện tử'],
'allow_post': True
}
result = create_product(data, 'YOUR_API_TOKEN')Response
{
"status": "success",
"message": "Tạo sản phẩm thành công",
"data": {
"id": 2,
"barcode": "SP002",
"main_barcode": "SP002",
"name": "Sản phẩm mới",
"list_price": 150000,
"price": 120000,
"description": "Mô tả sản phẩm mới",
"categories": ["Điện tử", "Công nghệ"],
"attributes": {
"Màu sắc": "Trắng",
"Kích thước": "L"
},
"images": [
"https://domain.com/public/uploads/products/2/image1.jpg",
"https://domain.com/public/uploads/products/2/image2.jpg"
],
"allow_post": true,
"apiget": 0,
"created_at": "2024-01-01 10:00:00",
"updated_at": "2024-01-01 10:00:00"
}
}4. Cập nhật sản phẩm
Theo ID
Endpoint: PUT /api/v2/products/{id}
Theo Barcode
Endpoint: PUT /api/v2/products/barcode/{barcode}
Request Body
{
"name": "Sản phẩm đã cập nhật",
"price": 110000,
"description": "Mô tả mới",
"categories": ["Điện tử"],
"attributes": {
"Màu sắc": "Xanh"
}
}# Cập nhật theo ID
curl -X PUT "https://your-domain.com/api/v2/products/1" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Sản phẩm đã cập nhật",
"price": 110000,
"description": "Mô tả mới"
}'
# Cập nhật theo Barcode
curl -X PUT "https://your-domain.com/api/v2/products/barcode/SP001" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Sản phẩm đã cập nhật",
"price": 110000,
"description": "Mô tả mới"
}'Cấu hình HTTP Request Node:
- URL:
https://your-domain.com/api/v2/products/1(hoặc/barcode/SP001) - Method:
PUT - Send Body:
true - Body Type:
JSON - Headers:
Authorization: Bearer YOUR_API_TOKEN Content-Type: application/json - Body (JSON):
{ "name": "Sản phẩm đã cập nhật", "price": 110000, "description": "Mô tả mới" }
function updateProduct($id, $data, $token) {
$url = "https://your-domain.com/api/v2/products/{$id}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token,
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Sử dụng
$data = [
'name' => 'Sản phẩm đã cập nhật',
'price' => 110000,
'description' => 'Mô tả mới'
];
$result = updateProduct(1, $data, 'YOUR_API_TOKEN');import requests
import json
def update_product(product_id, data, token):
url = f'https://your-domain.com/api/v2/products/{product_id}'
headers = {
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'
}
response = requests.put(url, headers=headers, data=json.dumps(data))
return response.json()
# Sử dụng
data = {
'name': 'Sản phẩm đã cập nhật',
'price': 110000,
'description': 'Mô tả mới'
}
result = update_product(1, data, 'YOUR_API_TOKEN')Response
{
"status": "success",
"message": "Cập nhật sản phẩm thành công",
"data": {
"id": 1,
"barcode": "SP001",
"main_barcode": "SP001",
"name": "Sản phẩm đã cập nhật",
"list_price": 100000,
"price": 110000,
"description": "Mô tả mới",
"categories": ["Điện tử"],
"attributes": {
"Màu sắc": "Xanh"
},
"images": [
"https://domain.com/public/uploads/products/1/image1.jpg"
],
"allow_post": true,
"apiget": 5,
"created_at": "2024-01-01 10:00:00",
"updated_at": "2024-01-01 11:00:00"
}
}5. Xóa sản phẩm
Endpoint: DELETE /api/v2/products/{id}
curl -X DELETE "https://your-domain.com/api/v2/products/1" \
-H "Authorization: Bearer YOUR_API_TOKEN"Cấu hình HTTP Request Node:
- URL:
https://your-domain.com/api/v2/products/1 - Method:
DELETE - Headers:
Authorization: Bearer YOUR_API_TOKEN
function deleteProduct($id, $token) {
$url = "https://your-domain.com/api/v2/products/{$id}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Sử dụng
$result = deleteProduct(1, 'YOUR_API_TOKEN');import requests
def delete_product(product_id, token):
url = f'https://your-domain.com/api/v2/products/{product_id}'
headers = {'Authorization': f'Bearer {token}'}
response = requests.delete(url, headers=headers)
return response.json()
# Sử dụng
result = delete_product(1, 'YOUR_API_TOKEN')Response
{
"status": "success",
"message": "Xóa sản phẩm thành công"
}6. Lấy sản phẩm ngẫu nhiên
Endpoint: GET /api/v2/products/random
Query Parameters
limit(optional): Số lượng sản phẩm (mặc định: 1, tối đa: 10)
curl -X GET "https://your-domain.com/api/v2/products/random?limit=5" \
-H "Authorization: Bearer YOUR_API_TOKEN"Cấu hình HTTP Request Node:
- URL:
https://your-domain.com/api/v2/products/random - Method:
GET - Query Parameters:
limit: 5 - Headers:
Authorization: Bearer YOUR_API_TOKEN
function getRandomProducts($limit = 1, $token) {
$url = "https://your-domain.com/api/v2/products/random?limit={$limit}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Sử dụng
$result = getRandomProducts(5, 'YOUR_API_TOKEN');import requests
def get_random_products(limit=1, token):
url = f'https://your-domain.com/api/v2/products/random?limit={limit}'
headers = {'Authorization': f'Bearer {token}'}
response = requests.get(url, headers=headers)
return response.json()
# Sử dụng
result = get_random_products(5, 'YOUR_API_TOKEN')Response
{
"status": "success",
"data": {
"id": 3,
"barcode": "SP003",
"main_barcode": "SP003",
"name": "Sản phẩm ngẫu nhiên",
"list_price": 200000,
"price": 180000,
"description": "Mô tả sản phẩm",
"categories": ["Thời trang"],
"attributes": {
"Chất liệu": "Cotton"
},
"images": [
"https://domain.com/public/uploads/products/3/image1.jpg"
],
"allow_post": true,
"apiget": 2,
"created_at": "2024-01-01 10:00:00",
"updated_at": "2024-01-01 10:00:00"
}
}7. Lấy danh sách danh mục
Endpoint: GET /api/v2/products/categories
curl -X GET "https://your-domain.com/api/v2/products/categories" \
-H "Authorization: Bearer YOUR_API_TOKEN"Cấu hình HTTP Request Node:
- URL:
https://your-domain.com/api/v2/products/categories - Method:
GET - Headers:
Authorization: Bearer YOUR_API_TOKEN
function getCategories($token) {
$url = 'https://your-domain.com/api/v2/products/categories';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Sử dụng
$categories = getCategories('YOUR_API_TOKEN');import requests
def get_categories(token):
url = 'https://your-domain.com/api/v2/products/categories'
headers = {'Authorization': f'Bearer {token}'}
response = requests.get(url, headers=headers)
return response.json()
# Sử dụng
categories = get_categories('YOUR_API_TOKEN')Response
{
"status": "success",
"data": [
{
"id": 1,
"name": "Điện tử",
"parent_id": null,
"sort_order": 1
},
{
"id": 2,
"name": "Thời trang",
"parent_id": null,
"sort_order": 2
},
{
"id": 3,
"name": "Công nghệ",
"parent_id": 1,
"sort_order": 1
}
]
}Quản lý hình ảnh
8. Upload hình ảnh cho sản phẩm
Theo ID
Endpoint: POST /api/v2/products/{id}/images
Theo Barcode
Endpoint: POST /api/v2/products/barcode/{barcode}/images
Request
- Content-Type:
multipart/form-data - Body:
images[]- Mảng file hình ảnh
# Upload theo ID
curl -X POST "https://your-domain.com/api/v2/products/1/images" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-F "images[]=@/path/to/image1.jpg" \
-F "images[]=@/path/to/image2.jpg"
# Upload theo Barcode
curl -X POST "https://your-domain.com/api/v2/products/barcode/SP001/images" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-F "images[]=@/path/to/image1.jpg" \
-F "images[]=@/path/to/image2.jpg"Cấu hình HTTP Request Node:
- URL:
https://your-domain.com/api/v2/products/1/images(hoặc/barcode/SP001/images) - Method:
POST - Send Body:
true - Body Type:
Form-Data - Headers:
Authorization: Bearer YOUR_API_TOKEN - Body (Form-Data):
images[]: [File upload]
function uploadProductImages($id, $imagePaths, $token) {
$url = "https://your-domain.com/api/v2/products/{$id}/images";
$ch = curl_init();
$postFields = [];
foreach ($imagePaths as $index => $path) {
$postFields["images[{$index}]"] = new CURLFile($path);
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Sử dụng
$imagePaths = ['/path/to/image1.jpg', '/path/to/image2.jpg'];
$result = uploadProductImages(1, $imagePaths, 'YOUR_API_TOKEN');import requests
def upload_product_images(product_id, image_paths, token):
url = f'https://your-domain.com/api/v2/products/{product_id}/images'
headers = {'Authorization': f'Bearer {token}'}
files = []
for i, path in enumerate(image_paths):
files.append(('images[]', open(path, 'rb')))
response = requests.post(url, headers=headers, files=files)
# Đóng files
for _, file_obj in files:
file_obj.close()
return response.json()
# Sử dụng
image_paths = ['/path/to/image1.jpg', '/path/to/image2.jpg']
result = upload_product_images(1, image_paths, 'YOUR_API_TOKEN')Response
{
"status": "success",
"message": "Upload hình ảnh thành công",
"data": {
"product_id": 1,
"barcode": "SP001",
"total_images": 3
}
}9. Xóa tất cả hình ảnh của sản phẩm
Theo ID
Endpoint: DELETE /api/v2/products/{id}/images
Theo Barcode
Endpoint: DELETE /api/v2/products/barcode/{barcode}/images
# Xóa theo ID
curl -X DELETE "https://your-domain.com/api/v2/products/1/images" \
-H "Authorization: Bearer YOUR_API_TOKEN"
# Xóa theo Barcode
curl -X DELETE "https://your-domain.com/api/v2/products/barcode/SP001/images" \
-H "Authorization: Bearer YOUR_API_TOKEN"Cấu hình HTTP Request Node:
- URL:
https://your-domain.com/api/v2/products/1/images(hoặc/barcode/SP001/images) - Method:
DELETE - Headers:
Authorization: Bearer YOUR_API_TOKEN
function deleteProductImages($id, $token) {
$url = "https://your-domain.com/api/v2/products/{$id}/images";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Sử dụng
$result = deleteProductImages(1, 'YOUR_API_TOKEN');import requests
def delete_product_images(product_id, token):
url = f'https://your-domain.com/api/v2/products/{product_id}/images'
headers = {'Authorization': f'Bearer {token}'}
response = requests.delete(url, headers=headers)
return response.json()
# Sử dụng
result = delete_product_images(1, 'YOUR_API_TOKEN')Response
{
"status": "success",
"message": "Xóa hình ảnh thành công",
"data": {
"product_id": 1,
"barcode": "SP001",
"deleted_files": 3,
"total_deleted": 3
}
}Xử lý lỗi
Các mã lỗi thường gặp
Validation Error (400)
{
"status": "error",
"message": "Validation failed",
"errors": {
"barcode": "Barcode is required",
"price": "Price must be greater than 0"
}
}Not Found Error (404)
{
"status": "error",
"message": "Không tìm thấy sản phẩm"
}Server Error (500)
{
"status": "error",
"message": "Có lỗi xảy ra khi xử lý yêu cầu"
}Quy tắc validation
Sản phẩm
barcode: Bắt buộc, tối thiểu 3 ký tựname: Bắt buộc, tối thiểu 2 ký tựlist_price: Bắt buộc, phải là số và lớn hơn 0price: Bắt buộc, phải là số và lớn hơn 0description: Tùy chọn, tối đa 1000 ký tự
Hình ảnh
- Chỉ hỗ trợ định dạng: JPG, PNG, GIF
- Kích thước tối đa: 10MB mỗi file
Rate Limiting
API có giới hạn 1000 requests mỗi giờ cho mỗi API key.
Mã trạng thái HTTP
200: Thành công201: Tạo thành công400: Lỗi validation404: Không tìm thấy500: Lỗi server
Ví dụ thực tế
Tạo workflow N8N hoàn chỉnh
- Trigger: Webhook để nhận dữ liệu sản phẩm
- Validate: Kiểm tra dữ liệu đầu vào
- Create Product: Tạo sản phẩm mới
- Upload Images: Upload hình ảnh nếu có
- Send Notification: Gửi thông báo thành công
Tích hợp với hệ thống khác
// JavaScript/Node.js example
const axios = require('axios');
class ProductAPI {
constructor(baseURL, token) {
this.baseURL = baseURL;
this.token = token;
this.headers = {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
};
}
async getProducts(params = {}) {
const response = await axios.get(`${this.baseURL}/api/v2/products`, {
headers: this.headers,
params
});
return response.data;
}
async createProduct(productData) {
const response = await axios.post(`${this.baseURL}/api/v2/products`, productData, {
headers: this.headers
});
return response.data;
}
async updateProduct(id, productData) {
const response = await axios.put(`${this.baseURL}/api/v2/products/${id}`, productData, {
headers: this.headers
});
return response.data;
}
async deleteProduct(id) {
const response = await axios.delete(`${this.baseURL}/api/v2/products/${id}`, {
headers: this.headers
});
return response.data;
}
}
// Sử dụng
const api = new ProductAPI('https://your-domain.com', 'YOUR_API_TOKEN');
const products = await api.getProducts({ limit: 10 });