※ 테스트 환경 : node v12.16.1
1. Node.js POST Request Example
1) 상품생성 API
const https = require('https');
const crypto = require('crypto');
const datetime = new Date().toISOString().substr(2,17).replace(/:/gi, '').replace(/-/gi, '') + 'Z';
const method ='POST';
const path ='/v2/providers/seller_api/apis/api/v1/marketplace/seller-products';
const query = '';
const message = datetime + method + path + query;
const urlpath = path + '?' + query;
//input your accessKey
const ACCESS_KEY = '';
//input your secretKey
const SECRET_KEY = '';
const algorithm = 'sha256';
const signature = crypto.createHmac(algorithm, SECRET_KEY)
.update(message)
.digest('hex');
const authorization = 'CEA algorithm=HmacSHA256, access-key=' + ACCESS_KEY + ', signed-date=' + datetime + ', signature=' + signature;
console.log(authorization);
const strjson = JSON.stringify(
{
"displayCategoryCode": 56137,
"sellerProductName": "상품등록_example",
"vendorId": "A00012345",
"saleStartedAt": "2020-05-01T00:00:00",
"saleEndedAt": "2099-01-01T23:59:59",
"displayProductName": "해피바스 솝베리 클렌징 오일",
"brand": "해피바스",
"generalProductName": "솝베리 클렌징 오일",
"productGroup": "클렌징 오일",
"deliveryMethod": "SEQUENCIAL",
"deliveryCompanyCode": "KGB",
"deliveryChargeType": "FREE",
"deliveryCharge": 0,
"freeShipOverAmount": 0,
"deliveryChargeOnReturn": 2500,
"remoteAreaDeliverable": "N",
"unionDeliveryType": "UNION_DELIVERY",
"returnCenterCode": "1000274592",
"returnChargeName": "반품지_1",
"companyContactNumber": "02-1234-678",
"returnZipCode": "135-090",
"returnAddress": "서울특별시 강남구 삼성동",
"returnAddressDetail": "333",
"returnCharge": 2500,
"outboundShippingPlaceCode": "74010",
"vendorUserId": "Your_WING_UserId",
"requested": false,
"items": [
{
"itemName": "200ml_1개",
"originalPrice": 13000,
"salePrice": 10000,
"maximumBuyCount": "100",
"maximumBuyForPerson": "0",
"outboundShippingTimeDay": "1",
"maximumBuyForPersonPeriod": "1",
"unitCount": 1,
"adultOnly": "EVERYONE",
"taxType": "TAX",
"parallelImported": "NOT_PARALLEL_IMPORTED",
"overseasPurchased": "NOT_OVERSEAS_PURCHASED",
"pccNeeded": "false",
"externalVendorSku": "0001",
"barcode": "",
"emptyBarcode": true,
"emptyBarcodeReason": "상품확인불가_바코드없음사유",
"modelNo": "1717171",
"extraProperties": null,
"certifications": [
{
"certificationType": "NOT_REQUIRED",
"certificationCode": ""
}
],
"searchTags": [
"검색어1",
"검색어2"
],
"images": [
{
"imageOrder": 0,
"imageType": "REPRESENTATION",
"vendorPath": "http://image11.coupangcdn.com/image/product/image/vendoritem/2018/06/25/3719529368/27a6b898-ff3b-4a27-b1e4-330a90c25e9c.jpg"
},
{
"imageOrder": 1,
"imageType": "DETAIL",
"vendorPath": "http://image11.coupangcdn.com/image/product/image/vendoritem/2018/06/25/3719529368/27a6b898-ff3b-4a27-b1e4-330a90c25e9c.jpg"
},
{
"imageOrder": 2,
"imageType": "DETAIL",
"vendorPath": "http://image11.coupangcdn.com/image/product/image/vendoritem/2018/06/25/3719529368/27a6b898-ff3b-4a27-b1e4-330a90c25e9c.jpg"
}
],
"notices": [
{
"noticeCategoryName": "화장품",
"noticeCategoryDetailName": "용량(중량)",
"content": "상세페이지 참조"
},
{
"noticeCategoryName": "화장품",
"noticeCategoryDetailName": "제품 주요 사양",
"content": "상세페이지 참조"
},
{
"noticeCategoryName": "화장품",
"noticeCategoryDetailName": "사용기한 또는 개봉 후 사용기간",
"content": "상세페이지 참조"
},
{
"noticeCategoryName": "화장품",
"noticeCategoryDetailName": "사용방법",
"content": "상세페이지 참조"
},
{
"noticeCategoryName": "화장품",
"noticeCategoryDetailName": "제조업자 및 제조판매업자",
"content": "상세페이지 참조"
},
{
"noticeCategoryName": "화장품",
"noticeCategoryDetailName": "제조국",
"content": "상세페이지 참조"
},
{
"noticeCategoryName": "화장품",
"noticeCategoryDetailName": "화장품법에 따라 기재, 표시하여야 하는 모든 성분",
"content": "상세페이지 참조"
},
{
"noticeCategoryName": "화장품",
"noticeCategoryDetailName": "식품의약품안전처 심사 필 유무",
"content": "상세페이지 참조"
},
{
"noticeCategoryName": "화장품",
"noticeCategoryDetailName": "사용할 때 주의사항",
"content": "상세페이지 참조"
},
{
"noticeCategoryName": "화장품",
"noticeCategoryDetailName": "품질보증기준",
"content": "제품 이상 시 공정거래위원회 고시 소비자분쟁해결기준에 의거 보상합니다."
},
{
"noticeCategoryName": "화장품",
"noticeCategoryDetailName": "소비자상담관련 전화번호",
"content": "상세페이지 참조"
}
],
"attributes": [
{
"attributeTypeName": "수량",
"attributeValueName": "1개"
}
],
"contents": [
{
"contentsType": "TEXT",
"contentDetails": [
{
"content": "http://image11.coupangcdn.com/image/product/image/vendoritem/2018/06/25/3719529368/27a6b898-ff3b-4a27-b1e4-330a90c25e9c.jpg",
"detailType": "TEXT"
}
]
}
],
"offerCondition": "NEW",
"offerDescription": ""
}
],
"requiredDocuments": [
{
"templateName": "기타인증서류",
"vendorDocumentPath": "http://image11.coupangcdn.com/image/product/content/vendorItem/2018/07/02/41579010/eebc0c30-8f35-4a51-8ffd-808953414dc1.jpg"
}
],
"extraInfoMessage": "",
"manufacture": "아모레퍼시픽"
}, null, 2);
//console.log(strjson);
const options = {
hostname: 'api-gateway.coupang.com',
port: 443,
path: urlpath,
method: method,
headers: {
'Content-Type': 'application/json;charset=UTF-8',
'Content-Length': Buffer.byteLength(strjson, 'utf8'),
'Authorization': authorization,
'X-EXTENDED-TIMEOUT':90000
}
};
let body = [];
const req = https.request(options, res => {
console.log(`statusCode: ${res.statusCode}`);
console.log(`reason: ${res.statusMessage}`);
res.on('data', (chunk) => {
body.push(chunk);
}).on('end', () => {
body = Buffer.concat(body).toString();
const json = JSON.parse(body);
console.log(JSON.stringify(json, null, 2));
});
});
req.on('error', error => {
console.error(error);
});
req.write(strjson);
req.end();
2. Node.js GET Request Example
1) 카테고리 메타정보조회 API
const https = require('https');
const crypto = require('crypto');
const datetime = new Date().toISOString().substr(2,17).replace(/:/gi, '').replace(/-/gi, '') + "Z";
const method ='GET';
const path ='/v2/providers/seller_api/apis/api/v1/marketplace/meta/category-related-metas/display-category-codes/77723';
const query = '';
const message = datetime + method + path + query;
const urlpath = path + '?' + query;
//input your accessKey
const ACCESS_KEY = '';
//input your secretKey
const SECRET_KEY = '';
const algorithm = 'sha256';
const signature = crypto.createHmac(algorithm, SECRET_KEY)
.update(message)
.digest('hex');
const authorization = 'CEA algorithm=HmacSHA256, access-key=' + ACCESS_KEY + ', signed-date=' + datetime + ', signature=' + signature;
console.log(authorization);
const options = {
hostname: 'api-gateway.coupang.com',
port: 443,
path: urlpath,
method: method,
headers: {
'Content-Type': 'application/json;charset=UTF-8',
'Authorization': authorization,
'X-EXTENDED-TIMEOUT':90000
}
};
let body = [];
const req = https.request(options, res => {
console.log(`statusCode: ${res.statusCode}`);
console.log(`reason: ${res.statusMessage}`);
res.on('data', (chunk) => {
body.push(chunk);
}).on('end', () => {
body = Buffer.concat(body).toString();
const json = JSON.parse(body);
console.log(JSON.stringify(json, null, 2));
});
});
req.on('error', error => {
console.error(error);
});
req.end();
2) 반품/취소 요청목록 조회 API
const https = require('https');
const crypto = require('crypto');
const datetime = new Date().toISOString().substr(2,17).replace(/:/gi, '').replace(/-/gi, '') + "Z";
const method ='GET';
const path ='/v2/providers/openapi/apis/api/v4/vendors/A000*****/returnRequests';
const query = 'createdAtFrom=2020-04-28&createdAtTo=2020-04-29&status=UC';
const message = datetime + method + path + query;
const urlpath = path + '?' + query;
//input your accessKey
const ACCESS_KEY = '';
//input your secretKey
const SECRET_KEY = '';
const algorithm = 'sha256';
const signature = crypto.createHmac(algorithm, SECRET_KEY)
.update(message)
.digest('hex');
const authorization = 'CEA algorithm=HmacSHA256, access-key=' + ACCESS_KEY + ', signed-date=' + datetime + ', signature=' + signature;
console.log(authorization);
const options = {
hostname: 'api-gateway.coupang.com',
port: 443,
path: urlpath,
method: method,
headers: {
'Content-Type': 'application/json;charset=UTF-8',
'Authorization': authorization,
'X-EXTENDED-TIMEOUT':90000
}
};
let body = [];
const req = https.request(options, res => {
console.log(`statusCode: ${res.statusCode}`);
console.log(`reason: ${res.statusMessage}`);
res.on('data', (chunk) => {
body.push(chunk);
}).on('end', () => {
body = Buffer.concat(body).toString();
const json = JSON.parse(body);
console.log(JSON.stringify(json, null, 2));
});
});
req.on('error', error => {
console.error(error);
});
req.end();
3. Node.js PUT Request Example
1) 상품수정 API
const https = require('https');
const crypto = require('crypto');
const datetime = new Date().toISOString().substr(2,17).replace(/:/gi, '').replace(/-/gi, '') + 'Z';
const method ='PUT';
const path ='/v2/providers/seller_api/apis/api/v1/marketplace/seller-products';
const query = '';
const message = datetime + method + path + query;
const urlpath = path + '?' + query;
//input your accessKey
const ACCESS_KEY = '';
//input your secretKey
const SECRET_KEY = '';
const algorithm = 'sha256';
const signature = crypto.createHmac(algorithm, SECRET_KEY)
.update(message)
.digest('hex');
const authorization = 'CEA algorithm=HmacSHA256, access-key=' + ACCESS_KEY + ', signed-date=' + datetime + ', signature=' + signature;
console.log(authorization);
const strjson = JSON.stringify(
{
"sellerProductId": 10673135163,
"sellerProductName": "상품등록_example",
"displayCategoryCode": 56137,
"categoryId": 1617,
"productId": null,
"vendorId": "A00012345",
"mdId": "NLUP_TEMP_SAVED",
"mdName": "dummy",
"saleStartedAt": "2020-05-07T12:06:26",
"saleEndedAt": "2099-01-01T23:59:59",
"displayProductName": "해피바스 솝베리 클렌징 오일",
"brand": "해피바스",
"generalProductName": "솝베리 클렌징 오일",
"productGroup": "클렌징 오일",
"statusName": "임시저장",
"deliveryMethod": "SEQUENCIAL",
"deliveryCompanyCode": "KGB",
"deliveryChargeType": "FREE",
"deliveryCharge": 0,
"freeShipOverAmount": 0,
"deliveryChargeOnReturn": 2500,
"deliverySurcharge": 0,
"remoteAreaDeliverable": "N",
"bundlePackingDelivery": 0,
"unionDeliveryType": "UNION_DELIVERY",
"returnCenterCode": "1000274592",
"returnChargeName": "반품지_1",
"companyContactNumber": "02-1234-678",
"returnZipCode": "135-090",
"returnAddress": "서울특별시 강남구 삼성동",
"returnAddressDetail": "333",
"returnCharge": 2500,
"outboundShippingPlaceCode": 74010,
"contributorType": "API_SELLER",
"vendorUserId": "Your_Wing_UserId",
"requested": false,
"items": [
{
"offerCondition": "NEW",
"offerDescription": "",
"sellerProductItemId": 11177656370,
"vendorItemId": null,
"itemId": null,
"itemName": "200ml_1개",
"originalPrice": 13000,
"salePrice": 10000,
"supplyPrice": 8614,
"maximumBuyCount": 100,
"maximumBuyForPerson": 0,
"outboundShippingTimeDay": 1,
"maximumBuyForPersonPeriod": 1,
"unitCount": 1,
"adultOnly": "EVERYONE",
"freePriceType": null,
"taxType": "TAX",
"parallelImported": "NOT_PARALLEL_IMPORTED",
"overseasPurchased": "NOT_OVERSEAS_PURCHASED",
"externalVendorSku": "0001",
"pccNeeded": false,
"bestPriceGuaranteed3P": false,
"emptyBarcode": true,
"emptyBarcodeReason": "상품확인불가_바코드없음사유",
"barcode": "",
"saleAgentCommission": 9.0,
"modelNo": "1717171",
"images": [
{
"imageOrder": 0,
"imageType": "REPRESENTATION",
"cdnPath": "vendor_inventory/df44/2fa342ee156e756498877afa3e74b60c8bf8a336013ff913f0f1a0a02672.jpg",
"vendorPath": "27a6b898-ff3b-4a27-b1e4-330a90c25e9c.jpg"
},
{
"imageOrder": 1,
"imageType": "DETAIL",
"cdnPath": "vendor_inventory/df44/2fa342ee156e756498877afa3e74b60c8bf8a336013ff913f0f1a0a02672.jpg",
"vendorPath": "27a6b898-ff3b-4a27-b1e4-330a90c25e9c.jpg"
},
{
"imageOrder": 2,
"imageType": "DETAIL",
"cdnPath": "vendor_inventory/df44/2fa342ee156e756498877afa3e74b60c8bf8a336013ff913f0f1a0a02672.jpg",
"vendorPath": "27a6b898-ff3b-4a27-b1e4-330a90c25e9c.jpg"
}
],
"notices": [
{
"noticeCategoryName": "화장품",
"noticeCategoryDetailName": "용량(중량)",
"content": "상세페이지 참조"
},
{
"noticeCategoryName": "화장품",
"noticeCategoryDetailName": "제품 주요 사양",
"content": "상세페이지 참조"
},
{
"noticeCategoryName": "화장품",
"noticeCategoryDetailName": "사용기한 또는 개봉 후 사용기간",
"content": "상세페이지 참조"
},
{
"noticeCategoryName": "화장품",
"noticeCategoryDetailName": "사용방법",
"content": "상세페이지 참조"
},
{
"noticeCategoryName": "화장품",
"noticeCategoryDetailName": "제조업자 및 제조판매업자",
"content": "상세페이지 참조"
},
{
"noticeCategoryName": "화장품",
"noticeCategoryDetailName": "제조국",
"content": "상세페이지 참조"
},
{
"noticeCategoryName": "화장품",
"noticeCategoryDetailName": "화장품법에 따라 기재, 표시하여야 하는 모든 성분",
"content": "상세페이지 참조"
},
{
"noticeCategoryName": "화장품",
"noticeCategoryDetailName": "식품의약품안전처 심사 필 유무",
"content": "상세페이지 참조"
},
{
"noticeCategoryName": "화장품",
"noticeCategoryDetailName": "사용할 때 주의사항",
"content": "상세페이지 참조"
},
{
"noticeCategoryName": "화장품",
"noticeCategoryDetailName": "품질보증기준",
"content": "제품 이상 시 공정거래위원회 고시 소비자분쟁해결기준에 의거 보상합니다."
},
{
"noticeCategoryName": "화장품",
"noticeCategoryDetailName": "소비자상담관련 전화번호",
"content": "상세페이지 참조"
}
],
"attributes": [
{
"attributeTypeName": "수량",
"attributeValueName": "1개",
"exposed": "EXPOSED",
"editable": false
}
],
"contents": [
{
"contentsType": "TEXT",
"contentDetails": [
{
"content": "http://image11.coupangcdn.com/image/product/image/vendoritem/2018/06/25/3719529368/27a6b898-ff3b-4a27-b1e4-330a90c25e9c.jpg",
"detailType": "TEXT"
}
]
}
],
"certifications": [
{
"certificationType": "NOT_REQUIRED",
"certificationCode": ""
}
],
"extraProperties": null,
"searchTags": [
"검색어1",
"검색어2"
],
"skuInfo": null
}
],
"requiredDocuments": [
{
"templateName": "기타인증서류",
"documentPath": "vendor_inventory/documents/2020/04/16/7/6/024c316cef9a71e3edb1f25af9b9ec62725b6003659e5a1c669fe2269d2091a1.jpg",
"vendorDocumentPath": "eebc0c30-8f35-4a51-8ffd-808953414dc1.jpg"
}
],
"extraInfoMessage": null,
"manufacture": "아모레퍼시픽",
"productOrigin": "",
"registrationType": "NORMAL"
}, null, 2);
//console.log(strjson);
const options = {
hostname: 'api-gateway.coupang.com',
port: 443,
path: urlpath,
method: method,
headers: {
'Content-Type': 'application/json;charset=UTF-8',
'Content-Length': Buffer.byteLength(strjson, 'utf8'),
'Authorization': authorization,
'X-EXTENDED-TIMEOUT':90000
}
};
let body = [];
const req = https.request(options, res => {
console.log(`statusCode: ${res.statusCode}`);
console.log(`reason: ${res.statusMessage}`);
res.on('data', (chunk) => {
body.push(chunk);
}).on('end', () => {
body = Buffer.concat(body).toString();
const json = JSON.parse(body);
console.log(JSON.stringify(json, null, 2));
});
});
req.on('error', error => {
console.error(error);
});
req.write(strjson);
req.end();
2) 상품 아이템별 가격 변경 API
const https = require('https');
const crypto = require('crypto');
const datetime = new Date().toISOString().substr(2,17).replace(/:/gi, '').replace(/-/gi, '') + 'Z';
const method = 'PUT';
const path = '/v2/providers/seller_api/apis/api/v1/marketplace/vendor-items/7039748***/prices/9000';
const query = 'forceSalePriceUpdate=true';
const message = datetime + method + path + query;
const urlpath = path + '?' + query;
//input your accessKey
const ACCESS_KEY = '';
//input your own secretKey
const SECRET_KEY = '';
const algorithm = 'sha256';
const signature = crypto.createHmac(algorithm, SECRET_KEY)
.update(message)
.digest('hex');
const authorization = 'CEA algorithm=HmacSHA256, access-key=' + ACCESS_KEY + ', signed-date=' + datetime + ', signature=' + signature;
console.log(authorization);
const options = {
hostname: 'api-gateway.coupang.com',
port: 443,
path: urlpath,
method: method,
headers: {
'Content-Type': 'application/json;charset=UTF-8',
'Authorization': authorization,
'X-EXTENDED-TIMEOUT':90000
}
};
let body = [];
const req = https.request(options, res => {
console.log(`statusCode: ${res.statusCode}`);
console.log(`reason: ${res.statusMessage}`);
res.on('data', (chunk) => {
body.push(chunk);
}).on('end', () => {
body = Buffer.concat(body).toString();
const json = JSON.parse(body);
console.log(JSON.stringify(json, null, 2));
});
});
req.on('error', error => {
console.error(error);
});
req.end();
4. Node.js DELETE Request Example
1) 상품삭제 API
const https = require('https');
const crypto = require('crypto');
const datetime = new Date().toISOString().substr(2,17).replace(/:/gi, '').replace(/-/gi, '') + "Z";
const method ='DELETE';
const path ='/v2/providers/seller_api/apis/api/v1/marketplace/seller-products/83358541';
const query = '';
const message = datetime + method + path + query;
const urlpath = path + '?' + query;
//input your accessKey
const ACCESS_KEY = '';
//input your secretKey
const SECRET_KEY = '';
const algorithm = 'sha256';
const signature = crypto.createHmac(algorithm, SECRET_KEY)
.update(message)
.digest('hex');
const authorization = 'CEA algorithm=HmacSHA256, access-key=' + ACCESS_KEY + ', signed-date=' + datetime + ', signature=' + signature;
console.log(authorization);
const options = {
hostname: 'api-gateway.coupang.com',
port: 443,
path: urlpath,
method: method,
headers: {
'Content-Type': 'application/json;charset=UTF-8',
'Authorization': authorization,
'X-EXTENDED-TIMEOUT':90000
}
};
let body = [];
const req = https.request(options, res => {
console.log(`statusCode: ${res.statusCode}`);
console.log(`reason: ${res.statusMessage}`);
res.on('data', (chunk) => {
body.push(chunk);
}).on('end', () => {
body = Buffer.concat(body).toString();
const json = JSON.parse(body);
console.log(JSON.stringify(json, null, 2));
});
});
req.on('error', error => {
console.error(error);
});
req.end();