45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
const axios = require('axios');
|
|
const API_KEY = 'sk-cKf0TV79X6Fp3CZwKfsnHv1Rq9GOK6nFCAXyDG9CvnIFKGYiTtSdOnjyadBaYc5y';
|
|
const baseUrl = 'https://yce-api-01.makeupar.com/s2s/v2.0';
|
|
|
|
async function test() {
|
|
try {
|
|
const initPayload = {
|
|
files: [
|
|
{ content_type: 'image/jpeg', file_name: 'test.jpg', file_size: 100000 }
|
|
]
|
|
};
|
|
|
|
console.log('Init...');
|
|
const res = await axios.post(`${baseUrl}/file`, initPayload, {
|
|
headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' }
|
|
});
|
|
|
|
const fileId = res.data.data.files[0].file_id;
|
|
console.log('File ID:', fileId);
|
|
|
|
console.log('Creating task...');
|
|
const taskPayload = {
|
|
src_file_id: fileId,
|
|
dst_actions: [
|
|
"wrinkle", "pore", "texture", "acne", "moisture", "eye_bag",
|
|
"firmness", "age_spot", "radiance", "redness", "oiliness"
|
|
],
|
|
miniserver_args: {
|
|
enable_mask_overlay: false
|
|
},
|
|
format: "json"
|
|
};
|
|
|
|
const taskRes = await axios.post(`${baseUrl}/task/skin-analysis`, taskPayload, {
|
|
headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' }
|
|
});
|
|
|
|
console.log('Task success:', taskRes.data);
|
|
} catch (err) {
|
|
console.error('Failed:', err.response ? err.response.status : err.message);
|
|
if(err.response) console.error(JSON.stringify(err.response.data, null, 2));
|
|
}
|
|
}
|
|
test();
|