Skip to main content
POST
Get recommendation sets

Description

A page with several rails, such as “For you”, “Similar items” and “Trending”, can ask for all of them in one request instead of one request per rail. Each set runs exactly as GET /v1/recommendations would run it, so a set returns the same results it would return on its own. The sets share the work they have in common. The visitor’s history is read once for the whole page, and two identical sets in one batch are computed once. Each set is billed as its own recommendation set, the same as a separate GET /v1/recommendations call: a batch of five different sets counts as five. Two identical sets in one batch are computed once and billed once.

Request

Each set takes: Pagination (mode, cursor, starting_after) is not part of a batch. Page through a rail with GET /v1/recommendations.

Response

results has one entry per set, in request order. A served set carries the same fields as a GET /v1/recommendations response, except the duplicate recommendations array. Send each set’s own request_id with the events from that rail so clicks are attributed to it. A set that fails comes back with its own status and error, and the other sets are still served. The batch itself fails only when the request is malformed or unauthorised. usage.sets is the number of sets in the batch. computed, reused and coalesced say how many were ranked, served again from an identical answer a moment earlier, or shared with an identical set in the same batch. Computed and reused sets are billed; a coalesced set is not, and it carries the same request_id as the set it shares, since it is the same answer. A reused set carries reuse: { "reused": true, "age_ms": … } and its own request_id.

SDKs

The TypeScript, PHP and Swift SDKs offer getRecommendationSets, and @neuronsearchlab/nextjs offers nsl.recommendSets. Each one splits a page of more than eight sets into several batches for you. The embed script batches placeholders on the same page automatically.

Errors

Authorizations

Authorization
string
header
required

The access token received from the authorization server in the OAuth 2.0 flow.

Body

application/json
requests
object[]
required

Identical sets in one batch are computed and billed once.

Required array length: 1 - 8 elements
user_id
string
anonymous_id
string
session_id
string
request_id
string<uuid>

Retrying with the same request_id is billed once.

Response

One result per set

object
enum<string>
required
Available options:
recommendation_set_list
request_id
string<uuid>
required
results
object[]
required

One result per request, in request order.

usage
object
required