Powered By GitBook
List all line items
How to fetch a collection of line items via API
To fetch a collection of line items, send a GET request to the /api/line_items endpoint.

Request

GET https://yourdomain.commercelayer.io/api/line_items

Example

Request
Response
The following request fetches a collection of line items:
1
curl -X GET \
2
https://yourdomain.commercelayer.io/api/line_items/ \
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 resource objects:
1
{
2
"data": [
3
{
4
"id": "xYZkjABcde",
5
"type": "line_items",
6
"links": {
7
"self": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde"
8
},
9
"attributes": {
10
"sku_code": "TSHIRTMM000000FFFFFFXLXX",
11
"bundle_code": "BUNDLEMM000000FFFFFFXLXX",
12
"quantity": 4,
13
"currency_code": "EUR",
14
"unit_amount_cents": 9900,
15
"unit_amount_float": 99.0,
16
"formatted_unit_amount": "€99,00",
17
"options_amount_cents": 990,
18
"options_amount_float": 9.9,
19
"formatted_options_amount": "€9,90",
20
"discount_cents": -900,
21
"discount_float": 9.0,
22
"formatted_discount": "€9,00",
23
"total_amount_cents": 18800,
24
"total_amount_float": 188.0,
25
"formatted_total_amount": "€188,00",
26
"tax_amount_cents": 1880,
27
"tax_amount_float": 18.8,
28
"formatted_tax_amount": "€18,80",
29
"name": "Black Men T-shirt with White Logo (XL)",
30
"image_url": "https://img.yourdomain.com/skus/xYZkjABcde.png",
31
"discount_breakdown": {
32
"41": {
33
"cents": -900,
34
"weight": 0.416
35
}
36
},
37
"tax_rate": 0.22,
38
"tax_breakdown": {
39
"id": "1234",
40
"city_amount": "0.0",
41
"state_amount": 6.6,
42
"city_tax_rate": 0.0,
43
"county_amount": 2.78,
44
"taxable_amount": 139.0,
45
"county_tax_rate": 0.02,
46
"tax_collectable": 10.08,
47
"special_tax_rate": 0.005,
48
"combined_tax_rate": 0.0725,
49
"city_taxable_amount": 0.0,
50
"state_sales_tax_rate": 0.0475,
51
"state_taxable_amount": 139.0,
52
"county_taxable_amount": 139.0,
53
"special_district_amount": 0.7,
54
"special_district_taxable_amount": 139.0
55
},
56
"item_type": "sku",
57
"created_at": "2018-01-01T12:00:00.000Z",
58
"updated_at": "2018-01-01T12:00:00.000Z",
59
"reference": "ANY-EXTERNAL-REFEFERNCE",
60
"reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
61
"metadata": {
62
"foo": "bar"
63
}
64
},
65
"relationships": {
66
"order": {
67
"links": {
68
"self": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/relationships/order",
69
"related": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/order"
70
}
71
},
72
"item": {
73
"links": {
74
"self": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/relationships/item",
75
"related": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/item"
76
}
77
},
78
"line_item_options": {
79
"links": {
80
"self": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/relationships/line_item_options",
81
"related": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/line_item_options"
82
}
83
},
84
"shipment_line_items": {
85
"links": {
86
"self": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/relationships/shipment_line_items",
87
"related": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/shipment_line_items"
88
}
89
},
90
"stock_line_items": {
91
"links": {
92
"self": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/relationships/stock_line_items",
93
"related": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/stock_line_items"
94
}
95
},
96
"stock_transfers": {
97
"links": {
98
"self": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/relationships/stock_transfers",
99
"related": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/stock_transfers"
100
}
101
}
102
},
103
"meta": {
104
"mode": "test"
105
}
106
},
107
{
108
"other": "... 9 line_items (first page)"
109
}
110
],
111
"meta": {
112
"record_count": 140,
113
"page_count": 14
114
},
115
"links": {
116
"first": "https://yourdomain.commercelayer.io/api/line_items?page[number]=1&page[size]=10",
117
"next": "https://yourdomain.commercelayer.io/api/line_items?page[number]=2&page[size]=10",
118
"last": "https://yourdomain.commercelayer.io/api/line_items?page[number]=14&page[size]=10"
119
}
120
}
Copied!

Sortable attributes

The list of line items can be sorted by the following attributes:
    total_amount_cents
    tax_amount_cents
    item_type
    id
    created_at
    updated_at
    reference
    reference_origin
Last modified 25d ago