Developer docs
ReX gives each household of your TV service personal rows of live TV and on-demand picks. Your apps do two things: report what is watched, and show the rows.
Overview
ReX is a web API. Every request carries your API key. There are two calls:
| Call | What it does |
|---|---|
POST /v1/events | Sends viewing events in batches: playback, watch time, details opened, cards shown, recommendations picked. |
GET /v1/rows | Returns a household's rows, best first, with what you need to draw them. |
ReX reads your catalogue (channels, programme guide, on-demand library) directly from your systems, so your apps only ever send your own ids. We set that connection up with you when you get your API key.
Base URL: https://api.rexai.tv. The machine-readable reference is openapi.json (OpenAPI 3.1).
Quick start
Report that a household watched a minute of channel 105:
curl -X POST "$REX_URL/v1/events" \
-H "x-rex-key: $REX_KEY" \
-H "content-type: application/json" \
-d '{
"events": [{
"id": "6f1c2a1e-4b7d-4c1e-9a55-0d2b8e1f3c77",
"type": "progress",
"at": "2026-11-27T20:41:00Z",
"householdId": "ACC-1234567",
"deviceId": "device-42",
"platform": "android",
"content": { "kind": "live", "channelId": "105" },
"watchedSeconds": 60
}]
}'
{"accepted": 1, "rejected": []}
Fetch that household's rows:
curl "$REX_URL/v1/rows?household=ACC-1234567" -H "x-rex-key: $REX_KEY"
{
"rows": [
{ "id": "new_episodes", "items": [
{ "kind": "live", "channelId": "105", "airingId": "EP012399",
"startsAt": "2026-11-28T02:00:00Z", "endsAt": "2026-11-28T03:00:00Z",
"title": "Harbour Lights", "subtitle": "The Long Night",
"image": "https://…", "channelName": "CTV", "channelLogo": "https://…" }
]},
{ "id": "popular", "items": [ { "kind": "vod", "titleId": "MV-881", "title": "…", "image": "https://…" } ] }
]
}
Building a web or smart TV app? The JavaScript library does all of this for you, including watch time and retries.
Households and devices
ReX recommends per household: send your own account id as householdId in every event, and ask for rows with the same id. Send a deviceId too (a stable id of the device or app install), and a profileId if your service has profiles.
ReX turns these ids into pseudonyms as they arrive and never stores the originals. Never send names, emails or other personal data in any field.
No household yet (a guest, or before sign-in)? Don't send events. Rows asked for a household ReX doesn't know yet are your service's general rows.
Content ids
Always use the ids from your own catalogue, the same ones ReX reads from it. content says what is watched:
kind | Send | How ReX matches it |
|---|---|---|
live | channelId | The programme on that channel at the event's time, from the guide. |
catchup, startover, recording | channelId and the guide entry's airingId | That guide entry on that channel. |
vod | titleId (and seriesId for an episode, when you have it) | The title in your on-demand library. |
Some guides reuse an entry's id for repeats or for the SD and HD versions of a channel. ReX handles that; when you match a row item back to your guide, use airingId together with startsAt.
Watch time
Watching is what ReX learns from most, so it is reported precisely:
play_startwhen playback starts;progressevery 60 seconds while playing, withwatchedSeconds: the seconds actually watched since the previous event of this playback (not counting pauses or seeking);play_stopwhen playback ends or the app closes, with the seconds since the lastprogress;- for live TV,
zapinstead ofplay_stopwhen the viewer changes channel, with the channel left.
Add positionSeconds and durationSeconds for on-demand, catch-up and recordings: that's how ReX knows a film was finished, and what to put in Continue watching.
Interest signals
For films and series, what people look at says a lot even before they press play. Three more events help:
details: a film's or series' details page closed, withdwellSecondsit was open (time while a player was open doesn't count).impression: the film and series cards that were on screen for at least a second during one visit of a screen, withsurface("home","movies"). Something shown again and again but never chosen is shown less.select: a ReX card was picked (see Counting plays from ReX).
All three are optional; rows work without them and get better with them.
Rows
Each row has an id; your app chooses the heading, in its own language. Rows come in order and each row's items are best first. A household gets only the rows that have something in them.
Row id | Contains | Updated |
|---|---|---|
continue_watching | On-demand titles and recordings started in the last 30 days and not finished, most recent first. | Nightly |
new_episodes | Episodes of shows the household follows that it hasn't seen: airing in the next two days on the channel it usually watches them on, or still in catch-up. | Nightly |
popular_now | Live programmes drawing the most viewers right now. | Every 15 minutes |
because_you_watched | Shows and films watched by households with similar taste. becauseOf / becauseOfTitle say which one led to them. | Nightly |
trending | Films and series catching interest across the service. | Nightly |
popular | The most watched across the service. | Nightly |
New row ids may be added over time: show rows you know and skip the others. Live items whose broadcast has ended are removed before the answer. Items carry what is needed to draw a card (title, subtitle, image, channelName, channelLogo); apps that have the full catalogue can use their own data, found by the ids.
Playing an item: a vod item opens that title. A live item on now plays its channel; one that starts later can open the channel or the guide entry. A catchup item plays that guide entry from catch-up, a recording the recording.
Counting plays from ReX
To show how much viewing ReX brings, playbacks that start from a ReX card are marked:
- When a viewer picks a ReX card, send a
selectevent with the card'scontent,source: "rex:<row id>"andsourcePosition(1 = first card). - If the same channel or title starts playing within 10 minutes, put the same
sourceandsourcePositionon every event of that playback (play_start,progress,play_stop). One pick marks at most one playback.
The JavaScript library does both with rex.select().
Authentication
Send your API key in the x-rex-key header. The key identifies your service and only allows sending events and reading rows, so it can ship inside your apps.
One exception: the last send while a web page closes uses fetch(…, { keepalive: true }) or sendBeacon, which can't carry custom headers. That request may put the key in the URL as ?key= and send the body as content-type: text/plain (it is still JSON). ReX doesn't keep request logs of such URLs.
The API allows calls from any web origin (CORS), as apps run on many.
POST /v1/events
Sends up to 500 events. Send in batches (every 30 to 60 seconds, and when the app goes to the background) and keep unsent events until ReX has answered: if a request fails, send the same events again. The event id makes sure nothing is counted twice.
Body
{ "events": [ ViewingEvent, … ] }, 1 to 500 events.
ViewingEvent
| Field | Type | Description |
|---|---|---|
id required | string | Unique per event (a UUID), so a resent batch is not counted twice. |
type required | "play_start" | "progress" | "play_stop" | "zap" | "record" | "remind" | "search" | "details" | "impression" | "select" | What happened (see the table of event types). |
at required | string (date-time) | When it happened (ISO 8601 with offset or Z). |
householdId required | string | The operator's account or household id. ReX stores only a pseudonym of it. |
profileId | string | Profile within the household, when the app has profiles. |
deviceId required | string | The device (stored as a pseudonym). |
platform required | string | What the app runs on: "web", "android", "ios", "lg", "tizen", "roku"… |
appVersion | string | The app's version. |
content | ContentRef | What was watched, picked or looked at. |
watchedSeconds | integer | Seconds actually watched since the previous event of this playback. |
positionSeconds | integer | Playback position. |
durationSeconds | integer | Length of the content. |
query | string | search: the search text. |
dwellSeconds | integer | details: seconds the details stayed open. |
items | ContentRef[] | impression: the titles shown. |
surface | string | impression: where they were shown ("home", "movies"). |
source | string | Where a playback or pick came from: "rex:<row id>" for a ReX row. |
sourcePosition | integer | Position of the picked card in its row (1 = first). |
ContentRef
Used in content and items.
| Field | Type | Description |
|---|---|---|
kind required | "live" | "catchup" | "startover" | "recording" | "vod" | How it is watched. |
channelId | string | The operator's channel id (live, catch-up, start-over, recordings). |
programmeId | string | Programme being watched, when the app knows it; otherwise ReX finds it from channel and time. |
airingId | string | The guide entry's id, as the operator's guide gives it. |
seriesId | string | The series, when known. |
titleId | string | VOD title id (kind: "vod"). |
Answer
202 with {"accepted": n, "rejected": [{"index", "id", "error"}]}. Each event is checked on its own: one invalid event never costs the others. Don't resend rejected events (they would be rejected again); log them and fix the app. Events of a type this version of ReX doesn't know yet are accepted and kept.
{
"accepted": 41,
"rejected": [{ "index": 7, "id": "1c0e…", "error": "at: Invalid ISO datetime" }]
}
Event types
type | When | Fields |
|---|---|---|
play_start | Playback starts | content |
progress | Every 60 s while playing | content, watchedSeconds, positionSeconds, durationSeconds |
play_stop | Playback stops, or the app closes | as progress |
zap | Live channel change | content of the channel left, watchedSeconds |
record | A recording is set | content |
remind | A reminder is set | content |
search | A search is made | query |
details | A film's or series' details close | content (kind: "vod", titleId), dwellSeconds |
impression | A screen visit ends (screen changes, app hidden, or every minute) | surface, items: films and series on screen for 1 s or more, each once per visit |
select | A ReX card is picked | content, source, sourcePosition |
Playback events of a playback that started from a ReX card also carry source and sourcePosition.
GET /v1/rows
| Parameter | Description |
|---|---|
household required | The same household id the app sends in events. |
packages | Comma-separated packages the household has; items from other packages are left out. Without it, nothing is filtered. |
Answer: 200 with {"rows": [Row, …]}. Answers may be cached for 60 seconds. Ask again when the home screen opens and every few minutes while it shows; the rows change overnight and, for what is on now, every 15 minutes.
Row
| Field | Type | Description |
|---|---|---|
id required | "continue_watching" | "new_episodes" | "popular_now" | "because_you_watched" | "popular" | "trending" | The row's kind. The app chooses the heading (in its own language) from it. |
items required | RowItem[] | In order: the first item is the best pick. |
RowItem
| Field | Type | Description |
|---|---|---|
kind required | "live" | "catchup" | "recording" | "vod" | What playing it means: a live channel, catch-up, a recording or a VOD title. |
channelId | string | The operator's channel id (live, catch-up, recordings). |
programmeId | string | The operator's programme id, when the guide has one. |
airingId | string | The guide entry, as the app sent it in events. Match it together with startsAt: repeats can share it. |
seriesId | string | The series, when known. |
titleId | string | The operator's VOD title id. |
startsAt | string | Start of the broadcast (ISO 8601). |
endsAt | string | End of the broadcast (ISO 8601). |
packages | string[] | Packages that include it. |
becauseOf | string | "Because you watched": the show or title that led to this one. |
title | string | Programme or title name, to draw the card. |
subtitle | string | Episode title. |
image | string | Poster (https). |
channelName | string | Channel name. |
channelLogo | string | Channel logo (https). |
becauseOfTitle | string | Name of becauseOf, for a heading such as "Because you watched …". |
Errors and limits
| Status | Body | Meaning |
|---|---|---|
401 | {"error": "unauthorized"} | Missing or unknown API key. |
400 | {"error": "invalid_batch"} | The body isn't a batch at all: not JSON, no events array, empty, or more than 500 events. |
400 | {"error": "invalid_query"} | household missing or too long. |
5xx | Try again later, with growing waits (for example 5 s, doubling, up to 5 minutes). |
Ids are at most 256 characters, watchedSeconds at most 3600 per event, query at most 200 characters, items at most 200 per event.
ReX should never get in the way of watching: if it can't be reached, keep events for later and show your usual home screen without ReX rows.
JavaScript library
@newfacetv/rex-client is for web apps, WebViews and smart TVs (it runs on browsers as old as Chromium 85, has no dependencies, and never throws into your app). It queues events across restarts, counts watch time, sends what is left when the page closes, tracks cards on screen and keeps one copy of the rows for the whole app.
npm install @newfacetv/rex-client
import { createRexClient } from '@newfacetv/rex-client';
const rex = createRexClient({
url: 'https://api.rexai.tv',
key: REX_KEY,
platform: 'web', // "android", "lg", "tizen"…
appVersion: '3.4.0',
deviceId: () => myDeviceId,
householdId: () => account?.id ?? null, // null: nothing is recorded
onError: (message) => console.warn('ReX:', message),
});
Playback
Start a tracked playback when your player opens and pass on its events. getContent is read at each report, so it can follow channel changes.
const playback = rex.playback(() => ({ kind: 'live', channelId: currentChannel.id }));
video.addEventListener('playing', () => playback.playing());
video.addEventListener('pause', () => playback.paused());
video.addEventListener('timeupdate', () => playback.position(video.currentTime, video.duration));
// when the player closes:
playback.end();
Details, screens and picks
// A film's details page opens:
const details = rex.details({ kind: 'vod', titleId: 'MV-881' });
// …and closes:
details.close();
// The screen showing, for impressions ("home", "movies", or null):
rex.screen('home');
// Each film or series card carries its title id:
// <div data-rex-title="MV-881">…</div>
// A ReX card is picked (row id and position, 1 = first), then play as usual:
rex.select({ row: 'popular', position: 3, content: { kind: 'vod', titleId: 'MV-881' } });
Cards inside dialogs ([role="dialog"]) or marked data-rex-overlay don't count as shown; change this with the impressions option.
Rows
const rows = await rex.rows({ packages: ['basic', 'sports'] });
// Or one shared copy, refreshed every 5 minutes while something shows it:
const stop = rex.rowsStore.subscribe((rows) => render(rows));
Options
| Option | Description |
|---|---|
url, key required | ReX's address and your API key. |
platform, deviceId, householdId required | As in events; the two ids are functions, read when needed. |
profileId, appVersion | Optional, as in events. |
events, rows | Turn either part off (default on). |
storage | Where unsent events wait; default localStorage, null for none. |
flushEverySeconds, progressEverySeconds | Default 30 and 60. |
rowsRefreshMs | Shared rows refresh (default 5 minutes). |
impressions | Card attribute, time on screen, overlay selector, visible share. |
onError | Told about failures; ReX never throws into your app. |
Also: rex.event(type, fields) for one-off events (record, remind, search), rex.flush(), rex.dispose().
React
import { RexProvider, useRexRows, useRexDetails, useRexScreen } from '@newfacetv/rex-client/react';
<RexProvider client={rex}><App /></RexProvider>
function Home() {
useRexScreen('home'); // impressions on this screen
const rows = useRexRows(); // the shared rows, kept fresh while shown
return rows.map((row) => <Row key={row.id} row={row} />);
}
function TitleDetails({ title }) {
useRexDetails({ kind: 'vod', titleId: title.id }); // a details event when it closes
…
}
Native apps
Android, iOS, tvOS, Roku and set-top box apps call the API directly. What the JavaScript library does, and yours should too:
- Give each event a random UUID as
idand the time it happened asat. - Keep events in a queue that survives restarts (up to about 500), and send them in batches of up to 100 every 30 to 60 seconds and when the app goes to the background.
- Remove events from the queue once ReX answers
202or400; on other failures keep them and try again with growing waits. - While playing, send
progressevery 60 seconds with the seconds actually watched since the last event; don't count pauses, buffering or seeking. - On a ReX card pick, send
selectand mark the playback that follows (see above). - Fetch rows when the home screen opens and every few minutes while it shows; on failure keep the rows you have.
Launch checklist
- The same household id in events and in rows requests, and no personal data in any field.
- Ids from your catalogue:
channelIdfor live,airingIdfor catch-up and recordings,titleIdfor on-demand. progressevery 60 s and a finalplay_stop(orzap), withwatchedSecondssince the previous event.- Events kept and resent when ReX can't be reached.
- Row headings for every row id you show, unknown ids skipped.
- Picks from ReX rows sent as
select, so you can see what ReX brings.