API docs
Reader data

API reference

Build your own player

Get a Reader's page sizes, word boxes, word times and file links, and highlight each word in a player of your own. Complete JavaScript example with PDF.js.

The hosted Reader is one iframe away (Embed Code). To show a Reader in a player of your own, with your own design, get its Reader data: the size of each page, every printed word with its box on the page and the time it is spoken, and links to the PDF and the audio.

Reader data is for PDF Builds. A Word List Build has no pages and no Reader; its Timings give the times by position.

Get Reader data#

GET/api/v1/readers/{reader_id}/data

Name the Reader by its short id, reader.id in the Build. A done Build's reader_data_url (also in its webhook) is this address.

It works for Public and Restricted Readers alike: your API Key is the authorization, so Allowed Sites are not checked. Call it from your server, never from a browser: the API Key must stay secret.

curl

curl https://app.shiurreader.com/api/v1/readers/0dibrutk/data \
  -H "Authorization: Bearer $SHIUR_READER_API_KEY"

Python

import os
import requests  # or httpx: the calls are the same

API = "https://app.shiurreader.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['SHIUR_READER_API_KEY']}"}
from datetime import datetime, timezone

data = requests.get(f"{API}/readers/0dibrutk/data", headers=HEADERS).json()

# Keep a copy of the PDF on your own server: the link expires at links_expire_at.
with open("0dibrutk.pdf", "wb") as pdf:
    pdf.write(requests.get(data["pdf_url"]).content)

for word in data["words"]:
    if word["status"] != "not_read":
        print(word["position"], word["text"], word["page"], word["box"], word["start"], word["end"])

expires = datetime.fromisoformat(data["links_expire_at"].replace("Z", "+00:00"))
if datetime.now(timezone.utc) >= expires:
    data = requests.get(f"{API}/readers/0dibrutk/data", headers=HEADERS).json()  # fresh links

JavaScript

const API = "https://app.shiurreader.com/api/v1";
const HEADERS = { Authorization: `Bearer ${process.env.SHIUR_READER_API_KEY}` };

// On your server: the API Key must never reach a browser.
async function readerData(readerId) {
  const response = await fetch(`${API}/readers/${readerId}/data`, { headers: HEADERS });
  if (!response.ok) throw new Error((await response.json()).error.message);
  return response.json();
}

const data = await readerData("0dibrutk");
const heard = data.words.filter((word) => word.status !== "not_read");
console.log(data.title, data.pages.length, "pages,", heard.length, "words timed");
console.log("Links work until", data.links_expire_at); // ask again after that
200 OK
{
  "id": "0dibrutk",
  "title": "Lehavin 6",
  "build_id": "cd4e2fd751c84d659936cdf0e0002da0",
  "duration_seconds": 5743.872,
  "visibility": "restricted",
  "reader_url": "https://app.shiurreader.com/r/0dibrutk",
  "audio_url": "https://files.shiurreader.com/cd4e2fd751c84d659936cdf0e0002da0/recording.mp3?X-Amz-Expires=21600&X-Amz-Signature=…",
  "pdf_url": "https://files.shiurreader.com/cd4e2fd751c84d659936cdf0e0002da0/reader/source.pdf?X-Amz-Expires=21600&X-Amz-Signature=…",
  "links_expire_at": "2026-10-11T15:00:00Z",
  "pages": [
    {
      "page": 1,
      "width": 2125,
      "height": 2750
    },
    {
      "page": 2,
      "width": 2126,
      "height": 2751
    }
  ],
  "words": [
    {
      "position": 0,
      "text": "ְהוּא",
      "page": 1,
      "box": {
        "x": 1154,
        "y": 720,
        "width": 75,
        "height": 47
      },
      "start": null,
      "end": null,
      "status": "not_read"
    },
    {
      "position": 1,
      "text": "חַסַוְשַלוּם,",
      "page": 1,
      "box": {
        "x": 414,
        "y": 1198,
        "width": 140,
        "height": 42
      },
      "start": 522.7,
      "end": 523.56,
      "status": "timed"
    },
    {
      "position": 2,
      "text": "ה\"",
      "page": 1,
      "box": {
        "x": 893,
        "y": 1893,
        "width": 35,
        "height": 27
      },
      "start": 523.56,
      "end": 523.84,
      "status": "filled"
    }
  ],
  "timing_status": "automatic_unverified"
}

Fields#

idstring
The Reader's short id.
titlestring
The Reader's current title.
build_idstring
The Build whose result the Reader shows (after a Rebuild, the Rebuild).
duration_secondsnumber
The Recording's length.
visibility"public" | "restricted"
As on the Readers page. It does not change this answer.
reader_urlstring
The hosted Reader page.
audio_urlstring
The audio (MP3) through a signed link that works until links_expire_at. For a Linked Recording, your own recording_url, which we never copy and which does not expire.
pdf_urlstring
The original PDF through a signed link that works until links_expire_at.
links_expire_atstring
When the signed links stop working: 6 hours after your request, ISO 8601 in UTC.
pagesarray
The size of each page that has words: page (from 1), width and height, in the same pixels as the word boxes.
wordsarray
Every printed word, in reading order. Below.
timing_statusstring
How the times were made. Today always automatic_unverified: found by the machine, not checked by a person.

Words#

The same names as Timings, plus where the word is printed.

positioninteger
The word's index in reading order: words[i].position == i.
textstring
The word as printed, with its vowels and punctuation.
pageinteger
The PDF page it is on, from 1.
boxobject
x, y, width, height: the word's rectangle in page pixels, from the page's top left corner.
start, endnumber or null
When the word is spoken, in seconds from the start of the Recording. null when not_read.
statusstring
timed, filled or not_read, as in Timings.

Coordinates#

Boxes are in page pixels: the PDF page drawn at 250 dpi (a US Letter page is 2125 by 2750). Each entry of pages gives that size. To place a box over the page as you show it, scale by your page's width:

Scaling
scale = shownPageWidth / page.width
left = box.x * scale      top = box.y * scale
width = box.width * scale height = box.height * scale

Pages keep their proportions, so one scale fits both directions. Draw the page any way you like: PDF.js on a canvas, or page images you made from the PDF.

audio_url and pdf_url are signed and short-lived: anyone holding them can download the files until links_expire_at, then they answer 403. Six hours covers a whole listen of the longest Recording. Ask for the Reader data again whenever you need fresh links, for example on each page load on your server; the words and pages stay the same.

Keep the PDF on your server

Our storage lets browsers play the audio from audio_url directly, but does not let other websites' scripts fetch() the PDF. Download it once on your server from pdf_url (or make page images from it) and serve it from your own site.

Highlighting the spoken word#

A shiur often explains as it reads, so long stretches of the Recording belong to no word. Light the last word whose start has passed, and keep it lit until the next one starts. Words that are not_read have no time: show them, but never light them.

A complete example#

This page plays the audio and highlights the current word over the PDF drawn with PDF.js. Your server answers /my-api/readers/0dibrutk/data by calling the API with your key, and serves the PDF it downloaded.

HTML
<audio id="audio" controls></audio>
<div id="pages"></div>
<style>
  .page { position: relative; margin: 1rem 0; }
  .page canvas { width: 100%; display: block; }
  .mark { position: absolute; background: rgb(255 210 0 / .4); border-radius: 3px; display: none; }
</style>
<script type="module">
import * as pdfjs from "https://cdn.jsdelivr.net/npm/pdfjs-dist@4.10.38/build/pdf.min.mjs";
pdfjs.GlobalWorkerOptions.workerSrc = "https://cdn.jsdelivr.net/npm/pdfjs-dist@4.10.38/build/pdf.worker.min.mjs";

// Your server calls GET /api/v1/readers/{id}/data with your API Key and returns the JSON,
// and serves the PDF it downloaded from pdf_url (storage links do not allow other sites' fetch()).
const data = await (await fetch("/my-api/readers/0dibrutk/data")).json();
const pdf = await pdfjs.getDocument("/my-api/readers/0dibrutk/source.pdf").promise;
document.getElementById("audio").src = data.audio_url;

const marks = new Map(); // page number -> { div, mark, size }
for (const size of data.pages) {
  const page = await pdf.getPage(size.page);
  const viewport = page.getViewport({ scale: 2 });
  const div = Object.assign(document.createElement("div"), { className: "page" });
  const canvas = Object.assign(document.createElement("canvas"), { width: viewport.width, height: viewport.height });
  const mark = Object.assign(document.createElement("div"), { className: "mark" });
  div.append(canvas, mark);
  document.getElementById("pages").append(div);
  await page.render({ canvasContext: canvas.getContext("2d"), viewport }).promise;
  marks.set(size.page, { div, mark, size });
}

// Words that were heard, by start time. The last one started stays lit through explanations.
const heard = data.words.filter((word) => word.start !== null).sort((a, b) => a.start - b.start);
let lit = null;
function highlight() {
  const time = document.getElementById("audio").currentTime;
  let low = 0, high = heard.length - 1, found = null;
  while (low <= high) {
    const middle = (low + high) >> 1;
    if (heard[middle].start <= time) { found = heard[middle]; low = middle + 1; } else high = middle - 1;
  }
  if (found !== lit) {
    for (const { mark } of marks.values()) mark.style.display = "none";
    if (found) {
      const { div, mark, size } = marks.get(found.page);
      const scale = div.clientWidth / size.width; // page pixels -> CSS pixels
      Object.assign(mark.style, { display: "block", left: `${found.box.x * scale}px`, top: `${found.box.y * scale}px`,
        width: `${found.box.width * scale}px`, height: `${found.box.height * scale}px` });
    }
    lit = found;
  }
  requestAnimationFrame(highlight);
}
requestAnimationFrame(highlight);
addEventListener("resize", () => { lit = null; }); // redraw the mark at the new scale
</script>

Errors#

404not_found
No such Reader in your Organization, or it was deleted.
401invalid_api_key
The API Key is missing, unknown or revoked.
429rate_limited
The same rate limit as every API request.
404 Not Found
{
  "error": {
    "code": "not_found",
    "message": "No Reader with this id in your Organization."
  }
}