Endpoints
Interactions
Record and retrieve user interactions with items (TAG, OFFER, SHOP, KEYWORD).
Interactions
curl --request POST \
--url https://api.example.com/user-interactions \
--header 'Content-Type: application/json' \
--data '
{
"interaction_type": "<string>",
"user_id": "<string>",
"student_id": {},
"item_type": "<string>",
"item_id": {},
"city": "<string>",
"country": "<string>",
"platform": "<string>",
"event_timestamp": {},
"source": "<string>",
"recommendation_id": {}
}
'import requests
url = "https://api.example.com/user-interactions"
payload = {
"interaction_type": "<string>",
"user_id": "<string>",
"student_id": {},
"item_type": "<string>",
"item_id": {},
"city": "<string>",
"country": "<string>",
"platform": "<string>",
"event_timestamp": {},
"source": "<string>",
"recommendation_id": {}
}
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({
interaction_type: '<string>',
user_id: '<string>',
student_id: {},
item_type: '<string>',
item_id: {},
city: '<string>',
country: '<string>',
platform: '<string>',
event_timestamp: {},
source: '<string>',
recommendation_id: {}
})
};
fetch('https://api.example.com/user-interactions', 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://api.example.com/user-interactions",
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([
'interaction_type' => '<string>',
'user_id' => '<string>',
'student_id' => [
],
'item_type' => '<string>',
'item_id' => [
],
'city' => '<string>',
'country' => '<string>',
'platform' => '<string>',
'event_timestamp' => [
],
'source' => '<string>',
'recommendation_id' => [
]
]),
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://api.example.com/user-interactions"
payload := strings.NewReader("{\n \"interaction_type\": \"<string>\",\n \"user_id\": \"<string>\",\n \"student_id\": {},\n \"item_type\": \"<string>\",\n \"item_id\": {},\n \"city\": \"<string>\",\n \"country\": \"<string>\",\n \"platform\": \"<string>\",\n \"event_timestamp\": {},\n \"source\": \"<string>\",\n \"recommendation_id\": {}\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://api.example.com/user-interactions")
.header("Content-Type", "application/json")
.body("{\n \"interaction_type\": \"<string>\",\n \"user_id\": \"<string>\",\n \"student_id\": {},\n \"item_type\": \"<string>\",\n \"item_id\": {},\n \"city\": \"<string>\",\n \"country\": \"<string>\",\n \"platform\": \"<string>\",\n \"event_timestamp\": {},\n \"source\": \"<string>\",\n \"recommendation_id\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/user-interactions")
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 \"interaction_type\": \"<string>\",\n \"user_id\": \"<string>\",\n \"student_id\": {},\n \"item_type\": \"<string>\",\n \"item_id\": {},\n \"city\": \"<string>\",\n \"country\": \"<string>\",\n \"platform\": \"<string>\",\n \"event_timestamp\": {},\n \"source\": \"<string>\",\n \"recommendation_id\": {}\n}"
response = http.request(request)
puts response.read_bodyImportant: User interaction records have dependencies on students. The
system validates the
student_id against existing records in the database.
You should upload student data before uploading user interaction records to
ensure proper data validation. The item_id field must reference the correct
item type as specified by item_type.Authentication Required
This endpoint may require API key authentication via Bearer token in the Authorization header.Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
About the Endpoint
This endpoint allows you to record and retrieve user interactions with items (TAG, OFFER, SHOP, KEYWORD).Source Field for Recommendation Feedback
Thesource field is crucial for tracking recommendation API effectiveness:
null: Normal user browsing interactions (not from recommendations)"COBI": Interactions that originated from recommendation API responses
- Track which recommendations led to user engagement
- Measure recommendation algorithm effectiveness
- Improve future recommendations based on user behavior patterns
Request Body
Response
The API returns a JSON response with the created interaction object on success.201 Createdon success400 Bad Requestif validation fails
Error Codes
| Status Code | Description |
|---|---|
| 201 | Interaction created successfully |
| 400 | Validation error |
| 401 | Unauthorized - Invalid API key |
| 500 | Internal server error |
Example
curl -X POST https://api.hellocobi.com/user-interactions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"interaction_type": "FILTER_CLICK",
"user_id": "75962b04e5caa7e582e2bc2949587ed9",
"student_id": "b1a2c3d4-e5f6-7890-abcd-1234567890ef",
"item_type": "TAG",
"item_id": "a1b2c3d4-e5f6-7890-abcd-1234567890ab",
"city": "Berlin",
"country": "Germany",
"platform": "WEB",
"event_timestamp": 1718035200,
"source": "COBI",
"recommendation_id": "6fc7eb1d-a516-4a9b-8dcc-313976461ae4"
}'
Was this page helpful?