Fetching resources
How to fetch single resources or collections
You can fetch either single resources or collections by sending GET requests to the resource endpoints.
The Accept header must be application/vnd.api+json.

Examples

Fetching a single SKU

Request
Response
The following request fetches a single SKU, the one identified by the ID "xYZkjABcde":
1
curl -g -X GET \
2
'https://yourdomain.commercelayer.io/api/skus/xYZkjABcde' \
3
-H 'Accept: application/vnd.api+json' \
4
-H 'Authorization: Bearer your-access-token'
Copied!
On success, the API responds with a 200 OK status code, returning a single resource object:
1
{
2
"data": {
3
"id": "xYZkjABcde",
4
"type": "skus",
5
"links": {...},
6
"attributes": {
7
"code": "TSHIRTMM000000FFFFFFXLXX",
8
"name": "Black Men T-shirt with White Logo (XL)",
9
"description": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
10
"image_url": "https://img.yourdomain.com/skus/xYZkjABcde.png",
11
"tag_names": "Men, Black, XL",
12
"pieces_per_pack": 6,
13
"weight": 300.0,
14
"unit_of_weight": "gr",
15
"hs_tariff_number": null,
16
"do_not_ship": false,
17
"do_not_track": false,
18
"inventory": {
19
"available": true,
20
"quantity": 10,
21
"levels": [
22
{
23
"quantity": 4,
24
"delivery_lead_times": [
25
{
26
"shipping_method": {
27
"name": "Standard Shipping",
28
"reference": null,
29
"price_amount_cents": 700,
30
"free_over_amount_cents": 9900,
31
"formatted_price_amount": "€7,00",
32
"formatted_free_over_amount": "€99,00"
33
},
34
"min": {
35
"hours": 72,
36
"days": 3
37
},
38
"max": {
39
"hours": 120,
40
"days": 5
41
}
42
},
43
{
44
"shipping_method": {
45
"name": "Express Delivery",
46
"reference": null,
47
"price_amount_cents": 1200,
48
"free_over_amount_cents": null,
49
"formatted_price_amount": "€12,00",
50
"formatted_free_over_amount": null
51
},
52
"min": {
53
"hours": 48,
54
"days": 2
55
},
56
"max": {
57
"hours": 72,
58
"days": 3
59
}
60
}
61
]
62
},
63
{
64
"quantity": 6,
65
"delivery_lead_times": [
66
{
67
"shipping_method": {
68
"name": "Standard Shipping",
69
"reference": null,
70
"price_amount_cents": 700,
71
"free_over_amount_cents": 9900,
72
"formatted_price_amount": "€7,00",
73
"formatted_free_over_amount": "€99,00"
74
},
75
"min": {
76
"hours": 96,
77
"days": 4
78
},
79
"max": {
80
"hours": 144,
81
"days": 6
82
}
83
},
84
{
85
"shipping_method": {
86
"name": "Express Delivery",
87
"reference": null,
88
"price_amount_cents": 1200,
89
"free_over_amount_cents": null,
90
"formatted_price_amount": "€12,00",
91
"formatted_free_over_amount": null
92
},
93
"min": {
94
"hours": 72,
95
"days": 3
96
},
97
"max": {
98
"hours": 96,
99
"days": 4
100
}
101
}
102
]
103
}
104
]
105
},
106
"created_at": "2018-01-01T12:00:00.000Z",
107
"updated_at": "2018-01-01T12:00:00.000Z",
108
"reference": "ANYREFEFERNCE",
109
"metadata": {
110
"foo": "bar"
111
}
112
},
113
"relationships": {
114
"shipping_category": {
115
"links": {...}
116
},
117
"prices": {
118
"links": {...}
119
},
120
"stock_items": {
121
"links": {...}
122
},
123
"delivery_lead_times": {
124
"links": {...}
125
},
126
"sku_options": {
127
"links": {...}
128
}
129
},
130
"meta": {
131
"mode": "test"
132
}
133
}
134
}
Copied!

Fetching a collection of SKUs

Request
Response
The following request fetches a collection of SKUs:
1
curl -g -X GET \
2
'https://yourdomain.commercelayer.io/api/skus' \
3
-H 'Accept: application/vnd.api+json' \
4
-H 'Authorization: Bearer your-access-token'
Copied!
On success, the API responds with a 200 OK status code, returning a paginated collection of the resource objects:
1
{
2
"data": [
3
{
4
"id": "xYZkjABcde",
5
"type": "skus",
6
"links": {...},
7
"attributes": {
8
"code": "TSHIRTMM000000FFFFFFXLXX",
9
"name": "Black Men T-shirt with White Logo (XL)",
10
"description": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
11
"image_url": "https://img.yourdomain.com/skus/xYZkjABcde.png",
12
"tag_names": "Men, Black, XL",
13
"pieces_per_pack": 6,
14
"weight": 300.0,
15
"unit_of_weight": "gr",
16
"hs_tariff_number": null,
17
"do_not_ship": false,
18
"do_not_track": false,
19
"created_at": "2018-01-01T12:00:00.000Z",
20
"updated_at": "2018-01-01T12:00:00.000Z",
21
"reference": "ANYREFEFERNCE",
22
"metadata": {
23
"foo": "bar"
24
}
25
},
26
"relationships": {
27
"shipping_category": {
28
"links": {...}
29
},
30
"prices": {
31
"links": {...}
32
},
33
"stock_items": {
34
"links": {...}
35
},
36
"delivery_lead_times": {
37
"links": {...}
38
},
39
"sku_options": {
40
"links": {...}
41
}
42
},
43
"meta": {
44
"mode": "test"
45
}
46
},
47
{
48
"other": "... 9 skus (first page)"
49
}
50
],
51
"meta": {
52
"record_count": 140,
53
"page_count": 14
54
},
55
"links": {
56
"first": "https://yourdomain.commercelayer.io/api/skus?page[number]=1&page[size]=10",
57
"next": "https://yourdomain.commercelayer.io/api/skus?page[number]=2&page[size]=10",
58
"last": "https://yourdomain.commercelayer.io/api/skus?page[number]=14&page[size]=10"
59
}
60
}
Copied!
When fetching SKUs with a market in scope only the SKUs that are sellable in that market are returned. To be sellable in a market an SKU must have a price in the market's price list and at least one stock item in one of the market's stock locations, regardless of its quantity.
Copy link
Contents
Examples