npm install skylab-studio
// CREATE PROFILE
const profilePayload = {
"name": "profile name",
"enable_crop": false,
"enable_retouch": true
}
const profile = await api.createProfile(profilePayload)
// CREATE JOB
const jobPayload = {
"name": "job name",
"profile_id": profile.id
}
const job = await api.createJob(jobPayload)
// UPLOAD JOB PHOTO(S)
const filePath = "/path/to/photo"
await api.uploadJobPhoto(filePath, job.id)
// QUEUE JOB
payload = { "callback_url" = "YOUR_CALLBACK_ENDPOINT" }
await api.queueJob(job.id, payload)
// NOTE: Once the job is queued, it will get processed then completed
// We will send a response to the specified callback_url with the output photo download urls
// After job has been completed, either download manually or download 1 photo:
await api.downloadPhoto(photoId, 'path/to/output/directory')
// or download all photos for a job:
await api.downloadPhotos(jobId, 'path/to/output/directory')
await api.listJobs();
await api.createJob({
name: "your job name",
profile_id: 123,
});
For all payload options, consult the API documentation.
await api.getJob(jobId);
await api.getJobByName(name);
await api.updateJob(jobId, { name: "updated job name", profile_id: 456 });
For all payload options, consult the API documentation.
const payload = {
callback_url: "desired_callback_url",
};
await api.queueJob(jobId, payload);
await api.getJobsInFront(jobId);
await api.deleteJob(jobId);
await api.cancelJob(jobId);
await api.listProfiles();
await api.createProfile({
name: "My Profile",
});
For all payload options, consult the API documentation.
await api.getProfile(profileId);
payload = {
name: "My updated profile name",
};
await api.updateProfile(profileId, payload);
For all payload options, consult the API documentation.
This function handles validating a photo, creating a photo object and uploading it to your job/profile's s3 bucket. If the bucket upload process fails, it retries 3 times and if failures persist, the photo object is deleted.
await api.uploadJobPhoto(photoPath, jobId);
Returns: { photo: { photoObject }, uploadResponse: bucketUploadResponseStatus }
If upload fails, the photo object is deleted for you. If upload succeeds and you later decide you no longer want to include that image, use delete_photo to remove it.
This function handles validating a background photo for a profile. Note: enable_extract
and replace_background
(profile attributes) MUST be true in order to create background photos. Follows the same upload process as uploadJobPhoto.
await api.uploadProfilePhoto(photoPath, profileId);
Returns: { photo: { photoObject }, uploadResponse: bucketUploadResponseStatus }
If upload fails, the photo object is deleted for you. If upload succeeds and you later decide you no longer want to include that image, use delete_photo to remove it.
await api.downloadPhoto(photoId, outputDirectoryPath);
Downloads an individual photo to specified output directory. (preferred over manually downloading)
Returns array of ofjects, [{ status, id }]
await api.downloadPhotos(jobId, outputDirectoryPath);
Downloads all photos for a job to specified output directory. (preferred over manually downloading)
Returns array of ofjects, [{ status, id }]
await api.getPhoto(photoId);
await api.deletePhoto(photoId);
- secretKey: Obtained from Skylab account (contact)
- jobJson: Raw JSON response from callback
- requestTimestamp: Timestamp header received in callback under 'X-Skylab-Timestamp'
- signature: Signature header received in callback under 'X-Skylab-Signature'
NOTE: If using something like an express server to handle the callback, the JSON response needs to be the raw response. If your express server is running app.use(express.json)
you will need to create a middleware and pass it to your callback handler to use the raw response: app.use(express.raw({ type: "application/json" }))
await api.validateHmacHeaders(secretKey, jobJson, requestTimestamp, signature);
- Enable debug mode
- Make sure you're using the latest Node client
- Capture the response data and check your logs — often this will have the exact error
Debug mode prints out the underlying request information as well as the data payload that gets sent to Skylab.
You will most likely find this information in your logs. To enable it, simply put debug=true
as a parameter
when instantiating the API object.
const skylabStudio = require("skylab-studio");
const api = skylabStudio("your-api-key", (debug = true));
SkylabTech's API typically sends responses back in these ranges:
- 2xx – Successful Request
- 4xx – Failed Request (Client error)
- 5xx – Failed Request (Server error)
If you're receiving an error in the 400 response range follow these steps:
- Double check the data and ID's getting passed to Skylab
- Ensure your API key is correct
- Log and check the body of the response