Getting started
Commerce Layer is free for developers, and it will be forever. So the best way to get started is to create an account and start building.
1. Create a test environment
After signup, you are prompted to create a sample organization with test data. This is the fastest way to get your feet wet and start playing with the API in test mode.
2. Get your credentials
Once your sample organization is ready, go to Settings → Applications and take note of your API credentials.
3. Get an access token
To get an access token, run the following in your terminal, making sure to replace your own endpoint and credentials:
curl -X POST \
http://the-amber-brand.commercelayer.io/oauth/token \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"grant_type": "client_credentials",
"client_id": "fb5eaa2b96c3a911602872e00c3e36d03cbeb1eac28143a1f0d7cac570d2cb1d",
"client_secret": "a6727cf33fd046e08c16e2b0bda55982c3289cf7c7596299ae01363288b5e832",
"scope": "market:1234"
}'
The response will look like this:
{
"access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJvcmdhbml6YXRpb24iOnsiaWQiOjU1fSwiYXBwbGljYXRpb24iOnsiaWQiOjU5LCJraW5kIjoiY2hhbm5lbCIsInB1YmxpYyI6ZmFsc2V9LCJ0ZXN0Ijp0cnVlLCJleHAiOjE1MzYxNTk2MzEsIm1hcmtldCI6eyJpZCI6NTMsInByaWNlX2xpc3RfaWQiOjUzLCJzdG9ja19sb2NhdGlvbl9pZHMiOls5MSw5Ml0sImdlb2NvZGVyX2lkIjpudWxsfX0.QBEBeEMGWWGjcZ980IYeenofXL1aAMLUbFybgLPYMLN16jpbjYhs2HO_rnQn4zVaX5kuywvxcik09WoWmUSUWA",
"token_type":"bearer",
"expires_in":7200,
"scope":"market:1234",
"created_at":1536152431
}
Take note of your access token — that will expire in 2 hours — and get ready for your first API call to Commerce Layer.
4. Make your first API call
As your first API call, you can get a list of SKUs. Run the following command in your terminal, making sure to replace the access token that you got in the previous step:
curl -X GET \
http://the-amber-brand.commercelayer.io/api/skus \
-H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJvcmdhbml6YXRpb24iOnsiaWQiOjU1fSwiYXBwbGljYXRpb24iOnsiaWQiOjU5LCJraW5kIjoiY2hhbm5lbCIsInB1YmxpYyI6ZmFsc2V9LCJ0ZXN0Ijp0cnVlLCJleHAiOjE1MzYxNTk2MzEsIm1hcmtldCI6eyJpZCI6NTMsInByaWNlX2xpc3RfaWQiOjUzLCJzdG9ja19sb2NhdGlvbl9pZHMiOls5MSw5Ml0sImdlb2NvZGVyX2lkIjpudWxsfX0.QBEBeEMGWWGjcZ980IYeenofXL1aAMLUbFybgLPYMLN16jpbjYhs2HO_rnQn4zVaX5kuywvxcik09WoWmUSUWA' \
-H 'Content-Type: application/vnd.api+json'
Congratulations! 🎉 You just made your first API call. Now, take the time to explore the rest of the reference, learn more about the available resources and become a pro 🙌.