SKULabs offers a JSON REST API which has all of the same power as the SKULabs app itself.
How to generate an API key
Go to settings -> advanced -> API to add an API key.
Authentication
You have three options to pass your Authentication header.
1. Header "Authorization: Bearer your_access_token_here"
2. Header "Authorization: SKULabsToken your_access_token_here"
3. Basic Authentication: Using any username and your API key as your password.
curl -u "skulabs:your_access_token_here"
How to use the API (Node.js 18 + Axios)
Prerequisites
Ensure you have axios
or a similar library installed in your preferably Node.js 18+ project.
npm install axios
Sample Code
const axios = require('axios');
// Replace 'your_access_token_here' with your actual access token const accessToken = 'your_access_token_here';
const config = {
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${accessToken}`
}
};
// Lets create a new location
const create_location_url = new URL('https://api.skulabs.com/location/create');
const postData = {
warehouse_id: '1234',
name: 'My New Location'
};
axios.post(create_location_url.toString(), postData, config)
.then(function (response) {
console.log('Response:', response.data);
}).catch(function (error) {
console.error('Error:', error);
});
// Now, let's get the list of locations.
const get_list_url = new URL('https://api.skulabs.com/location/get_list');
const selector = { warehouse_id: '1234' };
// Append the selector to the URL
get_list_url.searchParams.append('selector', JSON.stringify(selector));
axios.get(get_list_url.toString(), config)
.then(function (response) {
console.log('Response:', response.data);
}).catch(function (error) {
console.error('Error:', error);
});
Notes
Replace
'your_access_token_here'
with your actual access token for authentication.This script handles both successful and error responses from the API.
API Documentation
We have two documentation sites for our API.
https://www.skulabs.com/api/
This site contains a slightly older copy of our documentation with more examples.
A JSON file defining our API and providing a real-time up-to-date definition of our API. We recommend installing JSONViewer to format this documentation site.