๊ณต๊ธ์ ์ฒด API ๊ฐ์ด๋: ์๋ ์ฃผ๋ฌธ ์ฒ๋ฆฌ
Sarah Johnsonํ์ ์กฐ๊ฑด
์์ํ๊ธฐ ์ ์ ๋ค์์ ํ์ธํ์ธ์:
- API ์ ๊ทผ ๊ถํ์ด ์๋ ๊ณต๊ธ์ ์ฒด ๊ณ์
- API ํค (๊ณต๊ธ์ ์ฒด ๋์๋ณด๋์์ ์์ฑ ๊ฐ๋ฅ)
- Admin API v2 ์๋ํฌ์ธํธ ์ ๊ทผ ๊ถํ
๋จ๊ณ 1: API ํค ๊ฐ์ ธ์ค๊ธฐ
- ๊ณต๊ธ์ ์ฒด ๋์๋ณด๋์ ๋ก๊ทธ์ธํ์ธ์
- API ์ค์ (
/api-settings)์ผ๋ก ์ด๋ํ์ธ์ - API ํค๊ฐ ์๋ค๋ฉด "API ํค ์์ฑ"์ ํด๋ฆญํ์ธ์
- API ํค๋ฅผ ๋ณต์ฌํ๊ณ ์์ ํ๊ฒ ๋ณด๊ดํ์ธ์
์ค์: API ํค๋ ๋น๋ฐ๋ก ์ ์งํด์ผ ํฉ๋๋ค. ๊ณต๊ฐ์ ์ผ๋ก ๊ณต์ ํ๊ฑฐ๋ ๋ฒ์ ๊ด๋ฆฌ ์์คํ ์ ์ปค๋ฐํ์ง ๋ง์ธ์.
๋จ๊ณ 2: ์๋ ์ฃผ๋ฌธ ๊ฐ์ ธ์ค๊ธฐ
GET /api/admin/v2/orders ์๋ํฌ์ธํธ๋ฅผ ์ฌ์ฉํ์ฌ ๋๊ธฐ ์ค ๋ฐ ์ฒ๋ฆฌ ์ค์ธ ์๋ ์ฃผ๋ฌธ์ ๊ฐ์ ธ์ต๋๋ค.
API ์์ฒญ
curl -X GET "https://your-domain.com/api/admin/v2/orders?status=pending,processing&productType=manual&limit=50&offset=0" \
-H "X-Api-Key: YOUR_API_KEY"
์์ฒญ ๋งค๊ฐ๋ณ์
status(์ ํ์ฌํญ): ์ฃผ๋ฌธ ์ํ ํํฐ. ์ผํ๋ก ๊ตฌ๋ถ๋ ๊ฐ ์ง์:pending,processingproductType(์๋ ์ฃผ๋ฌธ ํ์):manual๋ก ์ค์ entityType(์ ํ์ฌํญ):product๋๋smm_service๋ก ํํฐ๋งsubCategory(์ ํ์ฌํญ): ํ์ ์นดํ ๊ณ ๋ฆฌ ์ด๋ฆ์ผ๋ก ํํฐ๋งlimit(์ ํ์ฌํญ): ๋ฐํํ ์ฃผ๋ฌธ ์ (์ต๋ 500, ๊ธฐ๋ณธ๊ฐ 50)offset(์ ํ์ฌํญ): ํ์ด์ง๋ค์ด์ ์คํ์ (๊ธฐ๋ณธ๊ฐ 0)
์๋ต ์์
{
"orders": [
{
"id": 12345,
"order": 12345,
"status": "pending",
"paymentStatus": "completed",
"quantity": 10,
"user": {
"id": "507f1f77bcf86cd799439011",
"email": "customer@example.com",
"name": "John Doe"
},
"items": [
{
"product": {
"id": "507f1f77bcf86cd799439012",
"name": "Instagram Followers",
"type": "product"
},
"quantity": 10,
"unitPrice": 5.00,
"totalPrice": 50.00
}
],
"createdAt": "2024-01-01T10:00:00.000Z"
}
],
"count": 1,
"total": 1
}
์ค์ ์ฌํญ
paymentStatus: "completed"์ธ ์ฃผ๋ฌธ๋ง ๋ฐํ๋ฉ๋๋ค- ์ค๋ณต ์ฒ๋ฆฌ๋ฅผ ๋ฐฉ์งํ๊ธฐ ์ํด ์ฃผ๋ฌธ์ด ํํฐ๋ง๋ฉ๋๋ค (30๋ถ ๊ฐ๊ฒฉ)
- ๊ณต๊ธ์ ์ฒด๋ก์ ๊ทํ์๊ฒ ์ํ ์ ํ/์๋น์ค์ ์ฃผ๋ฌธ๋ง ๋ณผ ์ ์์ต๋๋ค
๋จ๊ณ 3: ์ฃผ๋ฌธ ์ฒ๋ฆฌ ๋ฐ ๊ณ์ ์ ์ถ
์ฃผ๋ฌธ์ ๊ฐ์ ธ์จ ํ ์ฒ๋ฆฌํ๊ณ ๊ณ์ ์๊ฒฉ ์ฆ๋ช
์ ์ค๋นํ์ธ์. ๊ทธ๋ฐ ๋ค์ POST /api/admin/v2/orders-update ์๋ํฌ์ธํธ๋ฅผ ์ฌ์ฉํ์ฌ ๊ณ์ ์ ์ ์ถํ๊ณ ์ฃผ๋ฌธ ์ํ๋ฅผ ์
๋ฐ์ดํธํ์ธ์.
API ์์ฒญ
curl -X POST "https://your-domain.com/api/admin/v2/orders-update" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"order": 12345,
"status": "completed",
"accounts": [
"username1:password1",
"username2:password2",
"username3:password3"
],
"supplierOrderId": "SUP-ORDER-12345"
}'
์์ฒญ ๋ณธ๋ฌธ ๋งค๊ฐ๋ณ์
order(ํ์): ์ฃผ๋ฌธ ID (์ซ์)status(์ ํ์ฌํญ): ์๋ก์ด ์ฃผ๋ฌธ ์ํ. ์ ํจํ ๊ฐ:pending,processing,completed,partial,cancelled,erroraccounts(์ ํ์ฌํญ, ์ ํ ์ฃผ๋ฌธ์ฉ):"username:password"๋๋"email:password"ํ์์ ๊ณ์ ์๊ฒฉ ์ฆ๋ช ๋ฐฐ์ดsupplierOrderId(์ ํ์ฌํญ): ์ถ์ ์ ์ํ ๋ด๋ถ ์ฃผ๋ฌธ ID
๊ณ์ ํ์
์ ํ ์ฃผ๋ฌธ์ ๊ฒฝ์ฐ ๊ณ์ ์ ๋ฌธ์์ด ๋ฐฐ์ด๋ก ์ ๊ณต๋์ด์ผ ํฉ๋๋ค. ๊ฐ ๋ฌธ์์ด์ ํ๋์ ๊ณ์ ์ ๋ํ๋ ๋๋ค:
- ํ์:
"username:password"๋๋"email:password" - ์์:
["user1:pass123", "user2:pass456"] - ์๋: ์ฃผ๋ฌธ ์๋๊ณผ ์ผ์นํ๋ ๊ณ์ ์ ์ ๊ณตํ์ธ์
์์ ํ ์ํฌํ๋ก ์์
๋ค์์ JavaScript/Node.js๋ฅผ ์ฌ์ฉํ ์์ ํ ์์์ ๋๋ค:
const axios = require('axios');
const API_BASE_URL = 'https://your-domain.com/api/admin/v2';
const API_KEY = 'YOUR_API_KEY';
// ๋จ๊ณ 1: ๋๊ธฐ ์ค ๋ฐ ์ฒ๋ฆฌ ์ค์ธ ์๋ ์ฃผ๋ฌธ ๊ฐ์ ธ์ค๊ธฐ
async function getOrders() {
try {
const response = await axios.get(`${API_BASE_URL}/orders`, {
params: {
status: 'pending,processing',
productType: 'manual',
limit: 50,
offset: 0
},
headers: {
'X-Api-Key': API_KEY
}
});
return response.data.orders;
} catch (error) {
console.error('์ฃผ๋ฌธ ๊ฐ์ ธ์ค๊ธฐ ์ค๋ฅ:', error.response?.data || error.message);
throw error;
}
}
// ๋จ๊ณ 2: ์ฃผ๋ฌธ ์ฒ๋ฆฌ ๋ฐ ๊ณ์ ์ ์ถ
async function updateOrder(orderId, accounts, supplierOrderId) {
try {
const response = await axios.post(
`${API_BASE_URL}/orders-update`,
{
order: orderId,
status: 'completed',
accounts: accounts,
supplierOrderId: supplierOrderId
},
{
headers: {
'X-Api-Key': API_KEY,
'Content-Type': 'application/json'
}
}
);
return response.data;
} catch (error) {
console.error('์ฃผ๋ฌธ ์
๋ฐ์ดํธ ์ค๋ฅ:', error.response?.data || error.message);
throw error;
}
}
// ๋ฉ์ธ ์ํฌํ๋ก
async function processOrders() {
try {
// ์ฃผ๋ฌธ ๊ฐ์ ธ์ค๊ธฐ
const orders = await getOrders();
console.log(`์ฒ๋ฆฌํ ์ฃผ๋ฌธ ${orders.length}๊ฐ ๋ฐ๊ฒฌ`);
// ๊ฐ ์ฃผ๋ฌธ ์ฒ๋ฆฌ
for (const order of orders) {
console.log(`์ฃผ๋ฌธ ${order.id} ์ฒ๋ฆฌ ์ค...`);
// ๊ณ์ ์ค๋น (์ฌ๊ธฐ์ ์์คํ
์์ ๊ฐ์ ธ์ค๋ ๋ถ๋ถ)
const accounts = [
'user1:pass1',
'user2:pass2',
// ... order.quantity์ ์ผ์นํ๋ ๋ ๋ง์ ๊ณ์
];
// ๊ณ์ ์ผ๋ก ์ฃผ๋ฌธ ์
๋ฐ์ดํธ ๋ฐ ์๋ฃ๋ก ํ์
const updatedOrder = await updateOrder(
order.id,
accounts,
`SUP-${order.id}`
);
console.log(`์ฃผ๋ฌธ ${order.id} ์ฑ๊ณต์ ์ผ๋ก ์๋ฃ๋จ`);
}
} catch (error) {
console.error('์ํฌํ๋ก ์ค๋ฅ:', error);
}
}
// ์ํฌํ๋ก ์คํ
processOrders();
์ค๋ฅ ์ฒ๋ฆฌ
์ผ๋ฐ์ ์ธ ์ค๋ฅ
- ์๋ชป๋ API ํค
{ "error": "INVALID_API_KEY", "message": "์๋ชป๋ API ํค" }ํด๊ฒฐ ๋ฐฉ๋ฒ: API ํค๊ฐ ์ ํํ๊ณ ํ์ฑ ์ํ์ธ์ง ํ์ธํ์ธ์.
- ์ฃผ๋ฌธ์ ์ฐพ์ ์ ์์
{ "error": "ORDER_NOT_FOUND", "message": "์ฃผ๋ฌธ์ ์ฐพ์ ์ ์์" }ํด๊ฒฐ ๋ฐฉ๋ฒ: ์ฃผ๋ฌธ ID๊ฐ ์กด์ฌํ๊ณ ๊ทํ์๊ฒ ์ํ๋์ง ํ์ธํ์ธ์.
- ์ ๊ทผ ๊ฑฐ๋ถ๋จ
{ "error": "ACCESS_DENIED", "message": "์ด ์ฃผ๋ฌธ์ ๋ํ ์ ๊ทผ ๊ถํ์ด ์์ต๋๋ค" }ํด๊ฒฐ ๋ฐฉ๋ฒ: ์ฃผ๋ฌธ์ ๊ทํ์๊ฒ ์ํ ์ ํ/์๋น์ค๊ฐ ํฌํจ๋์ด ์๋์ง ํ์ธํ์ธ์.
- ์๋ชป๋ ๊ณ์
{ "error": "INVALID_ACCOUNTS", "message": "์ค๋ณต ์ ๊ฑฐ ํ ์ ํจํ ๊ณ์ ์ด ์ ๊ณต๋์ง ์์์ต๋๋ค" }ํด๊ฒฐ ๋ฐฉ๋ฒ: ๊ณ์ ๋ฐฐ์ด์ด ๋น์ด ์์ง ์๊ณ ์ ํจํ ๋ฌธ์์ด์ ํฌํจํ๋์ง ํ์ธํ์ธ์.
๋ชจ๋ฒ ์ฌ๋ก
- ํด๋ง ๋น๋: ๋๋ฌด ์์ฃผ ํด๋งํ์ง ๋ง์ธ์. API๋ 30๋ถ ๊ฐ๊ฒฉ์ผ๋ก ์ค๋ณต ์ฒ๋ฆฌ๋ฅผ ๋ฐฉ์งํฉ๋๋ค.
- ์ค๋ฅ ์ฒ๋ฆฌ: ํญ์ ์ ์ ํ ์ค๋ฅ ์ฒ๋ฆฌ ๋ฐ ์ฌ์๋ ๋ก์ง์ ๊ตฌํํ์ธ์.
- ๊ณ์ ๊ฒ์ฆ: ์ ์ถํ๊ธฐ ์ ์ ๊ณ์ ์ด ์ฌ๋ฐ๋ฅธ ํ์์ธ์ง ๋ฐ๋์ ๊ฒ์ฆํ์ธ์.
- ์ฃผ๋ฌธ ์ถ์ : ์์คํ
๋ด์์ ์ฃผ๋ฌธ์ ์ถ์ ํ๋ ค๋ฉด
supplierOrderId๋ฅผ ์ฌ์ฉํ์ธ์. - ์ํ ์
๋ฐ์ดํธ: ์ํ๋ฅผ ์ ์ง์ ์ผ๋ก ์
๋ฐ์ดํธํ ์ ์์ต๋๋ค:
- ์ฒ๋ฆฌ ์์ ์ ๋จผ์
processing์ผ๋ก ์ค์ - ๊ณ์ ์ค๋น ์๋ฃ ์
completed๋ก ์ค์
- ์ฒ๋ฆฌ ์์ ์ ๋จผ์
- ๋ถ๋ถ ์ฃผ๋ฌธ: ์ฃผ๋ฌธ์ ์ผ๋ถ๋ง ์ดํํ ์ ์๋ ๊ฒฝ์ฐ, ์ํ๋ฅผ
partial๋ก ์ค์ ํ๊ณ ์ฌ์ฉ ๊ฐ๋ฅํ ๊ณ์ ์ ์ ์ถํ์ธ์.
์์ฝ
์ ์ฒด ์ํฌํ๋ก๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
- ์ฃผ๋ฌธ ๊ฐ์ ธ์ค๊ธฐ:
GET /api/admin/v2/orders?status=pending,processing&productType=manual - ์ฃผ๋ฌธ ์ฒ๋ฆฌ: ๊ฐ ์ฃผ๋ฌธ์ ๋ํ ๊ณ์ ์ค๋น
- ๊ณ์ ์ ์ถ: ๊ณ์ ๊ณผ
status: "completed"๋ฅผ ํฌํจํPOST /api/admin/v2/orders-update
์ด ๊ฐ๋จํ 3๋จ๊ณ ํ๋ก์ธ์ค๋ฅผ ํตํด ์ฃผ๋ฌธ ์ดํ ์ํฌํ๋ก๋ฅผ ์์ ํ ์๋ํํ ์ ์์ต๋๋ค!
๋ ๋ค ํต์ฌ ๊ณต๊ธ์ ์ฒด ๋ฌธ์ ๊ฐ์ด๋์ ๋๋ค. ์ด๋ค์ ์ฐ๊ฒฐํ๋ฉด ๊ณต๊ธ์ ์ฒด๊ฐ ์ ํ ์ค์ ์์ ์ฃผ๋ฌธ ์ฒ๋ฆฌ๋ก ์ํํ๊ฒ ์ด๋ํ๋ฉฐ ๋ ผ๋ฆฌ์ ์ธ ์ํฌํ๋ก๋ฅผ ๋ง๋ค ์ ์์ต๋๋ค. ์ ํ ๊ด๋ฆฌ ๊ฐ์ด๋.

Sarah Johnson
Digital marketing expert with 10+ years of experience in social media strategy. Passionate about helping businesses grow their online presence through effective marketing techniques.


