Recommendations
Register an add-to-cart event
Registers that a product recommended by a specific widget was added to the cart
POST
/
api
/
widget
/
{widget_id}
/
cart
Register an add-to-cart event
curl --request POST \
--url https://{search_zone}-recommendations.doofinder.com/api/widget/{widget_id}/cart \
--header 'Content-Type: application/json' \
--data '
{
"session_id": "b2b89619844f4eb0b5fa19f28a19d679",
"dfid": "123e4567e89b12d3a456426614174000@product@e7b7a6c35b2d4afc94991bfc8100227a",
"title": "<string>",
"price": 123,
"amount": 1
}
'import requests
url = "https://{search_zone}-recommendations.doofinder.com/api/widget/{widget_id}/cart"
payload = {
"session_id": "b2b89619844f4eb0b5fa19f28a19d679",
"dfid": "123e4567e89b12d3a456426614174000@product@e7b7a6c35b2d4afc94991bfc8100227a",
"title": "<string>",
"price": 123,
"amount": 1
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
session_id: 'b2b89619844f4eb0b5fa19f28a19d679',
dfid: '123e4567e89b12d3a456426614174000@product@e7b7a6c35b2d4afc94991bfc8100227a',
title: '<string>',
price: 123,
amount: 1
})
};
fetch('https://{search_zone}-recommendations.doofinder.com/api/widget/{widget_id}/cart', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{search_zone}-recommendations.doofinder.com/api/widget/{widget_id}/cart",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'session_id' => 'b2b89619844f4eb0b5fa19f28a19d679',
'dfid' => '123e4567e89b12d3a456426614174000@product@e7b7a6c35b2d4afc94991bfc8100227a',
'title' => '<string>',
'price' => 123,
'amount' => 1
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{search_zone}-recommendations.doofinder.com/api/widget/{widget_id}/cart"
payload := strings.NewReader("{\n \"session_id\": \"b2b89619844f4eb0b5fa19f28a19d679\",\n \"dfid\": \"123e4567e89b12d3a456426614174000@product@e7b7a6c35b2d4afc94991bfc8100227a\",\n \"title\": \"<string>\",\n \"price\": 123,\n \"amount\": 1\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{search_zone}-recommendations.doofinder.com/api/widget/{widget_id}/cart")
.header("Content-Type", "application/json")
.body("{\n \"session_id\": \"b2b89619844f4eb0b5fa19f28a19d679\",\n \"dfid\": \"123e4567e89b12d3a456426614174000@product@e7b7a6c35b2d4afc94991bfc8100227a\",\n \"title\": \"<string>\",\n \"price\": 123,\n \"amount\": 1\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{search_zone}-recommendations.doofinder.com/api/widget/{widget_id}/cart")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"session_id\": \"b2b89619844f4eb0b5fa19f28a19d679\",\n \"dfid\": \"123e4567e89b12d3a456426614174000@product@e7b7a6c35b2d4afc94991bfc8100227a\",\n \"title\": \"<string>\",\n \"price\": 123,\n \"amount\": 1\n}"
response = http.request(request)
puts response.read_body{
"status": "OK"
}{
"error": "Bad request",
"details": {
"session_id": [
"length must be less than or equal to 32"
],
"user_id": [
"is required"
],
"current_url": [
"is required"
]
}
}{
"error": "Forbidden origin"
}{
"error": "Not found",
"resource": "Widget",
"resource_id": "cc1e4567-e89b-12d3-a456-426614174000"
}{
"error": "Too many request"
}Path Parameters
Unique identifier for the widget
Example:
"123e4567-e89b-12d3-a456-426614174000"
Body
application/json
Session identifier for tracking user behavior
Example:
"b2b89619844f4eb0b5fa19f28a19d679"
Doofinder's unique ID for the item added to the cart
Example:
"123e4567e89b12d3a456426614174000@product@e7b7a6c35b2d4afc94991bfc8100227a"
The item title
The item price
Quantity added to the cart (optional, default 1)
Example:
1
Response
Add-to-cart event processed, check the status field for the outcome
Available options:
OK, ERROR Example:
"OK"
⌘I
Register an add-to-cart event
curl --request POST \
--url https://{search_zone}-recommendations.doofinder.com/api/widget/{widget_id}/cart \
--header 'Content-Type: application/json' \
--data '
{
"session_id": "b2b89619844f4eb0b5fa19f28a19d679",
"dfid": "123e4567e89b12d3a456426614174000@product@e7b7a6c35b2d4afc94991bfc8100227a",
"title": "<string>",
"price": 123,
"amount": 1
}
'import requests
url = "https://{search_zone}-recommendations.doofinder.com/api/widget/{widget_id}/cart"
payload = {
"session_id": "b2b89619844f4eb0b5fa19f28a19d679",
"dfid": "123e4567e89b12d3a456426614174000@product@e7b7a6c35b2d4afc94991bfc8100227a",
"title": "<string>",
"price": 123,
"amount": 1
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
session_id: 'b2b89619844f4eb0b5fa19f28a19d679',
dfid: '123e4567e89b12d3a456426614174000@product@e7b7a6c35b2d4afc94991bfc8100227a',
title: '<string>',
price: 123,
amount: 1
})
};
fetch('https://{search_zone}-recommendations.doofinder.com/api/widget/{widget_id}/cart', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{search_zone}-recommendations.doofinder.com/api/widget/{widget_id}/cart",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'session_id' => 'b2b89619844f4eb0b5fa19f28a19d679',
'dfid' => '123e4567e89b12d3a456426614174000@product@e7b7a6c35b2d4afc94991bfc8100227a',
'title' => '<string>',
'price' => 123,
'amount' => 1
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{search_zone}-recommendations.doofinder.com/api/widget/{widget_id}/cart"
payload := strings.NewReader("{\n \"session_id\": \"b2b89619844f4eb0b5fa19f28a19d679\",\n \"dfid\": \"123e4567e89b12d3a456426614174000@product@e7b7a6c35b2d4afc94991bfc8100227a\",\n \"title\": \"<string>\",\n \"price\": 123,\n \"amount\": 1\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{search_zone}-recommendations.doofinder.com/api/widget/{widget_id}/cart")
.header("Content-Type", "application/json")
.body("{\n \"session_id\": \"b2b89619844f4eb0b5fa19f28a19d679\",\n \"dfid\": \"123e4567e89b12d3a456426614174000@product@e7b7a6c35b2d4afc94991bfc8100227a\",\n \"title\": \"<string>\",\n \"price\": 123,\n \"amount\": 1\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{search_zone}-recommendations.doofinder.com/api/widget/{widget_id}/cart")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"session_id\": \"b2b89619844f4eb0b5fa19f28a19d679\",\n \"dfid\": \"123e4567e89b12d3a456426614174000@product@e7b7a6c35b2d4afc94991bfc8100227a\",\n \"title\": \"<string>\",\n \"price\": 123,\n \"amount\": 1\n}"
response = http.request(request)
puts response.read_body{
"status": "OK"
}{
"error": "Bad request",
"details": {
"session_id": [
"length must be less than or equal to 32"
],
"user_id": [
"is required"
],
"current_url": [
"is required"
]
}
}{
"error": "Forbidden origin"
}{
"error": "Not found",
"resource": "Widget",
"resource_id": "cc1e4567-e89b-12d3-a456-426614174000"
}{
"error": "Too many request"
}