Order History API

Overview

The order History API enables you to send order data to engage. While the Javascript source will catch order data through events happening now, this source let you send historic data to quickly add enough data to train the machine learning models, such as the recommendation engine.

Add this source

  1. 1.
    Log into your engage account
  2. 2.
    Click "Add sources" on the home page and select the Order History API
  3. 3.
    Follow the instructions to get started

Use this source

Once activated, you may start to send orders to us. The endpoint accept single orders or batches of maximum 250 orders at a time. Check the API Reference for specifics and code examples in most languages.
post
https://api-dot-solutionsone-211314.ew.r.appspot.com
/v1/orders
Historic Order API

Example call

cURL
Javascript - jQuery
Javascript - Fetch
Nodejs - Axios
PHP - cURL
Python
1
curl --location --request POST 'https://api-dot-solutionsone-211314.ew.r.appspot.com/v1/orders'
2
--header 'Authorization: Bearer [ADD YOUR USER TOKEN HERE]' \
3
--header 'Content-Type: application/json'
4
--data-raw '{
5
"city": "New York",
6
"country": "USA",
7
"currency": "USD",
8
"date_created_gmt": "2020-01-01 20:20:01+01:00",
9
"email": "[email protected]",
10
"order_id": 20200101,
11
"status": "completed",
12
"order_value": 40.00,
13
"line_items":[
14
{
15
"line_item_product_id": 1002,
16
"line_item_price": 17.49,
17
"line_item_quantity": 1,
18
"line_item_name": "Any name",
19
"line_item_sku": "sku 123",
20
"line_item_variation_id": 1234,
21
"line_item_subtotal": 17.49,
22
"line_item_total": 17.49,
23
"line_item_tax_class": "Class A",
24
"line_item_subtotal_tax": 0,
25
"line_item_total_tax": 0
26
}
27
]
28
}'
Copied!
1
var settings = {
2
"url": "https://api-dot-solutionsone-211314.ew.r.appspot.com/v1/orders",
3
"method": "POST",
4
"timeout": 0,
5
"headers": {
6
"Authorization": "Bearer [ADD YOUR USER TOKEN HERE]",
7
"Content-Type": "application/json"
8
},
9
"data": JSON.stringify({"city":"New York","country":"USA","currency":"USD","date_created_gmt":"2020-01-01 20:20:01+01:00","email":"[email protected]","order_id":20200102,"status":"completed","order_value":40,"line_items":[{"line_item_product_id":1002,"line_item_price":17.49,"line_item_quantity":1,"line_item_name":"Any name","line_item_sku":"sku 123","line_item_variation_id":1234,"line_item_subtotal":17.49,"line_item_total":17.49,"line_item_tax_class":"Class A","line_item_subtotal_tax":0,"line_item_total_tax":0}]}),
10
};
11
12
$.ajax(settings).done(function (response) {
13
console.log(response);
14
});
Copied!
1
var myHeaders = new Headers();
2
myHeaders.append("Authorization", "Bearer [ADD YOUR USER TOKEN HERE]");
3
myHeaders.append("Content-Type", "application/json");
4
5
var raw = JSON.stringify({"city":"New York","country":"USA","currency":"USD","date_created_gmt":"2020-01-01 20:20:01+01:00","email":"[email protected]","order_id":20200102,"status":"completed","order_value":40,"line_items":[{"line_item_product_id":1002,"line_item_price":17.49,"line_item_quantity":1,"line_item_name":"Any name","line_item_sku":"sku 123","line_item_variation_id":1234,"line_item_subtotal":17.49,"line_item_total":17.49,"line_item_tax_class":"Class A","line_item_subtotal_tax":0,"line_item_total_tax":0}]});
6
7
var requestOptions = {
8
method: 'POST',
9
headers: myHeaders,
10
body: raw,
11
redirect: 'follow'
12
};
13
14
fetch("https://api-dot-solutionsone-211314.ew.r.appspot.com/v1/orders", requestOptions)
15
.then(response => response.text())
16
.then(result => console.log(result))
17
.catch(error => console.log('error', error));
Copied!
1
var axios = require('axios');
2
var data = JSON.stringify({"city":"New York","country":"USA","currency":"USD","date_created_gmt":"2020-01-01 20:20:01+01:00","email":"[email protected]","order_id":20200102,"status":"completed","order_value":40,"line_items":[{"line_item_product_id":1002,"line_item_price":17.49,"line_item_quantity":1,"line_item_name":"Any name","line_item_sku":"sku 123","line_item_variation_id":1234,"line_item_subtotal":17.49,"line_item_total":17.49,"line_item_tax_class":"Class A","line_item_subtotal_tax":0,"line_item_total_tax":0}]});
3
4
var config = {
5
method: 'post',
6
url: 'https://api-dot-solutionsone-211314.ew.r.appspot.com/v1/orders',
7
headers: {
8
'Authorization': 'Bearer [ADD YOUR USER TOKEN HERE]',
9
'Content-Type': 'application/json'
10
},
11
data : data
12
};
13
14
axios(config)
15
.then(function (response) {
16
console.log(JSON.stringify(response.data));
17
})
18
.catch(function (error) {
19
console.log(error);
20
});
Copied!
1
<?php
2
3
$curl = curl_init();
4
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => "https://api-dot-solutionsone-211314.ew.r.appspot.com/v1/orders",
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_ENCODING => "",
9
CURLOPT_MAXREDIRS => 10,
10
CURLOPT_TIMEOUT => 0,
11
CURLOPT_FOLLOWLOCATION => true,
12
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
13
CURLOPT_CUSTOMREQUEST => "POST",
14
CURLOPT_POSTFIELDS =>"{\"city\": \"New York\",\"country\": \"USA\",\"currency\": \"USD\",\"date_created_gmt\": \"2020-01-01 20:20:01+01:00\",\"email\": \"[email protected]\",\"order_id\": 20200102,\"status\": \"completed\",\"order_value\": 40.00,\"line_items\":[ { \"line_item_product_id\": 1002,\"line_item_price\": 17.49,\"line_item_quantity\": 1,\"line_item_name\": \"Any name\",\"line_item_sku\": \"sku 123\",\"line_item_variation_id\": 1234,\"line_item_subtotal\": 17.49,\"line_item_total\": 17.49,\"line_item_tax_class\": \"Class A\",\"line_item_subtotal_tax\": 0,\"line_item_total_tax\": 0 } ] }",
15
CURLOPT_HTTPHEADER => array(
16
"Authorization: Bearer [ADD YOUR USER TOKEN HERE]",
17
"Content-Type: application/json"
18
),
19
));
20
21
$response = curl_exec($curl);
22
23
curl_close($curl);
24
echo $response;
25
Copied!
1
import requests
2
import json
3
4
url = "https://api-dot-solutionsone-211314.ew.r.appspot.com/v1/orders"
5
6
order = {
7
"city": "New York",
8
"country": "USA",
9
"currency": "USD",
10
"date_created_gmt": "2020-01-01 20:20:01+01:00",
11
"email": "[email protected]",
12
"order_id": 20200102,
13
"status": "completed",
14
"order_value": 40.00,
15
"line_items": [
16
{
17
"line_item_product_id": 1002,
18
"line_item_price": 17.49,
19
"line_item_quantity": 1,
20
"line_item_name": "Any name",
21
"line_item_sku": "sku 123",
22
"line_item_variation_id": 1234,
23
"line_item_subtotal": 17.49,
24
"line_item_total": 17.49,
25
"line_item_tax_class": "Class A",
26
"line_item_subtotal_tax": 0,
27
"line_item_total_tax": 0
28
}
29
]
30
}
31
payload = json.dumps(order)
32
headers = {
33
'Authorization': 'Bearer [ADD YOUR USER TOKEN HERE]',
34
'Content-Type': 'application/json'
35
}
36
37
response = requests.request("POST", url, headers=headers, data = payload)
38
39
print(response.text.encode('utf8'))
40
Copied!

Data formats

Dates & Time

Format
Example
YYYY-MM-DD HH:MM:SS+HH:MM
2020-01-01 04:23:01+04:00
YYYY-MM-DD HH:MM:SS.ffffff
2020-01-01 04:23:01.000384
YYYY-MM-DD HH:MM:SS
2020-01-01 04:23:01
YYYY-MM-DDTHH:MM:SS+HH:MM
2020-01-01T04:23:01+04:00
YYYY-MM-DDTHH:MM:SS.ffffff
2020-01-01T04:23:01.000384
YYYY-MM-DDTHH:MM:SS
2020-01-01T04:23:01

Generic format supported

1
YYYY-MM-DD[*HH[:MM[:SS[.fff[fff]]]][+HH:MM[:SS[.ffffff]]]]
Copied!
Last modified 8mo ago