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:

CallWhat it does
POST /v1/eventsSends viewing events in batches: playback, watch time, details opened, cards shown, recommendations picked.
GET /v1/rowsReturns 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:

kindSendHow ReX matches it
livechannelIdThe programme on that channel at the event's time, from the guide.
catchup, startover, recordingchannelId and the guide entry's airingIdThat guide entry on that channel.
vodtitleId (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:

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:

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 idContainsUpdated
continue_watchingOn-demand titles and recordings started in the last 30 days and not finished, most recent first.Nightly
new_episodesEpisodes 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_nowLive programmes drawing the most viewers right now.Every 15 minutes
because_you_watchedShows and films watched by households with similar taste. becauseOf / becauseOfTitle say which one led to them.Nightly
trendingFilms and series catching interest across the service.Nightly
popularThe 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:

  1. When a viewer picks a ReX card, send a select event with the card's content, source: "rex:<row id>" and sourcePosition (1 = first card).
  2. If the same channel or title starts playing within 10 minutes, put the same source and sourcePosition on 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

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

FieldTypeDescription
id requiredstringUnique 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 requiredstring (date-time)When it happened (ISO 8601 with offset or Z).
householdId requiredstringThe operator's account or household id. ReX stores only a pseudonym of it.
profileIdstringProfile within the household, when the app has profiles.
deviceId requiredstringThe device (stored as a pseudonym).
platform requiredstringWhat the app runs on: "web", "android", "ios", "lg", "tizen", "roku"…
appVersionstringThe app's version.
contentContentRefWhat was watched, picked or looked at.
watchedSecondsintegerSeconds actually watched since the previous event of this playback.
positionSecondsintegerPlayback position.
durationSecondsintegerLength of the content.
querystringsearch: the search text.
dwellSecondsintegerdetails: seconds the details stayed open.
itemsContentRef[]impression: the titles shown.
surfacestringimpression: where they were shown ("home", "movies").
sourcestringWhere a playback or pick came from: "rex:<row id>" for a ReX row.
sourcePositionintegerPosition of the picked card in its row (1 = first).

ContentRef

Used in content and items.

FieldTypeDescription
kind required"live" | "catchup" | "startover" | "recording" | "vod"How it is watched.
channelIdstringThe operator's channel id (live, catch-up, start-over, recordings).
programmeIdstringProgramme being watched, when the app knows it; otherwise ReX finds it from channel and time.
airingIdstringThe guide entry's id, as the operator's guide gives it.
seriesIdstringThe series, when known.
titleIdstringVOD 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

typeWhenFields
play_startPlayback startscontent
progressEvery 60 s while playingcontent, watchedSeconds, positionSeconds, durationSeconds
play_stopPlayback stops, or the app closesas progress
zapLive channel changecontent of the channel left, watchedSeconds
recordA recording is setcontent
remindA reminder is setcontent
searchA search is madequery
detailsA film's or series' details closecontent (kind: "vod", titleId), dwellSeconds
impressionA 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
selectA ReX card is pickedcontent, source, sourcePosition

Playback events of a playback that started from a ReX card also carry source and sourcePosition.

GET /v1/rows

GET/v1/rows?household=ACC-1234567&packages=basic,sports
ParameterDescription
household requiredThe same household id the app sends in events.
packagesComma-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

FieldTypeDescription
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 requiredRowItem[]In order: the first item is the best pick.

RowItem

FieldTypeDescription
kind required"live" | "catchup" | "recording" | "vod"What playing it means: a live channel, catch-up, a recording or a VOD title.
channelIdstringThe operator's channel id (live, catch-up, recordings).
programmeIdstringThe operator's programme id, when the guide has one.
airingIdstringThe guide entry, as the app sent it in events. Match it together with startsAt: repeats can share it.
seriesIdstringThe series, when known.
titleIdstringThe operator's VOD title id.
startsAtstringStart of the broadcast (ISO 8601).
endsAtstringEnd of the broadcast (ISO 8601).
packagesstring[]Packages that include it.
becauseOfstring"Because you watched": the show or title that led to this one.
titlestringProgramme or title name, to draw the card.
subtitlestringEpisode title.
imagestringPoster (https).
channelNamestringChannel name.
channelLogostringChannel logo (https).
becauseOfTitlestringName of becauseOf, for a heading such as "Because you watched …".

Errors and limits

StatusBodyMeaning
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.
5xxTry 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

OptionDescription
url, key requiredReX's address and your API key.
platform, deviceId, householdId requiredAs in events; the two ids are functions, read when needed.
profileId, appVersionOptional, as in events.
events, rowsTurn either part off (default on).
storageWhere unsent events wait; default localStorage, null for none.
flushEverySeconds, progressEverySecondsDefault 30 and 60.
rowsRefreshMsShared rows refresh (default 5 minutes).
impressionsCard attribute, time on screen, overlay selector, visible share.
onErrorTold 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:

Launch checklist