UNPKG

4.88 kBMarkdownView Raw
1# HTTP API
2
3`r2-streamer-js` contains an Express server with support for the following routes:
4
5## GET /opds2/publications.json
6
7This route serves the list of available publications as an "OPDS 2" JSON file using the `application/opds+json` content type.
8
9More information about the OPDS format here: https://github.com/opds-community/
10
11The `?canonical=true` URL query string parameter can be used to generate a sorted JSON with no pretty-printing (no indentation).
12
13## GET /opds2/publications.json/show (also redirect from /opds2)
14
15This route serves a pretty-printed representation of the "OPDS 2" JSON, with clickable links for easy navigation / visualization (e.g. the cover image of each listed publication).
16
17`/show` is equivalent to `/show/all`. Here is a list of available JSON "filters": Metadata = `/show/metadata`, Links = `/show/links`, Publications = `/show/publications`.
18
19Alternatively, the `show` URL query string parameter can be used (e.g. `/opds2/publications.json?show=all`).
20
21A JSON-Schema validation report is presented at the bottom of the page, based on the official OPDS2 schema (see `./misc/json-schema/opds/`).
22
23## GET /pub/{PUB_ID}
24
25`{PUB_ID}` is the base64 encoding of a local publication file (server filesystem, therefore limited to app-approved files), or of any arbitrary HTTP URL (see [remote-epub.md](remote-epub.md)).
26
27For demonstration purposes, the deployed server apps include `wasteland-otf-obf.epub` and `childrens-literature.epub`, obtained from https://idpf.github.io/epub3-samples/samples.html / https://github.com/IDPF/epub3-samples
28
29For testing purposes, the served HTML page contains a list of links to available online readers / Readium2 navigators.
30
31### GET /pub/{PUB_ID}/manifest.json
32
33This route serves the "webpub manifest" JSON file using the `application/webpub+json` content type.
34
35The `?canonical=true` URL query string parameter can be used to generate a sorted JSON with no pretty-printing (no indentation).
36
37### GET /pub/{PUB_ID}/manifest.json/show
38
39This route serves a pretty-printed representation of the "webpub manifest" JSON, with clickable links for easy navigation into individual publication assets (see next route below).
40
41`/show` is equivalent to `/show/all`. Here is a list of available JSON "filters": Cover image = `/show/cover`, Table of Contents = `/show/toc`, Metadata = `/show/metadata`, Spine = `/show/spine`, Page List = `/show/pagelist`, Landmarks = `/show/landmarks`, Links = `/show/links`, Resources = `/show/resources`, Media Overlays = `/show/mediaoverlays`.
42
43Alternatively, the `show` URL query string parameter can be used (e.g. `/pub/{PUB_ID}/manifest.json?show=all`).
44
45The cover image (if any) is always displayed at the top of the served HTML page.
46
47A JSON-Schema validation report is presented at the bottom of the page, based on the official ReadiumWebPubManifest schema (see `./misc/json-schema/webpub-manifest/`).
48
49### GET /pub/{PUB_ID}/{ASSET_PATH}
50
51This route serves individual assets (file resources) from the publication. `{ASSET_PATH}` is relative to the root of the ebook container (e.g. EPUB zip archive), so files like `/META-INF/container.xml` can be requested.
52
53Text files can be rendered in-page (for debugging) rather than processed by the web browser, by using the `?show=1` URL query string parameter.
54
55### GET /pub/{PUB_ID}/media-overlay
56
57This route serves the full EPUB3 Media Overlay SMIL data (in its JSON form) using the `application/vnd.syncnarr+json` content type. Single spine item Media Overlays can be requested using the `/media-overlay?resource={ASSET_PATH}` URL query parameter (`{ASSET_PATH}` has the same definition as in the above section).
58
59The `?canonical=true` URL query string parameter can be used to generate a sorted JSON with no pretty-printing (no indentation).
60
61### GET /pub/{PUB_ID}/media-overlay/show
62
63This route serves a pretty-printed representation of the Media Overlays JSON, with clickable links for easy navigation / visualization (e.g. clipped audio files playback directly in the web browsers).
64
65Alternatively, the `show` URL query string parameter can be used (e.g. `/pub/{PUB_ID}/media-overlay?show=1`).
66
67Warning: large SMIL files are likely to crush performance when pretty-printing the outputed JSON.
68
69## GET /url/ and /url/{ENCODED_URL}
70
71This conveninent micro-service automatically redirects to the base64 route described in the above section (`/pub/{PUB_ID}`). See [remote-epub.md](remote-epub.md).
72
73## GET /opds-v1-browse/ and /opds-v1-browse/{ENCODED_URL}
74
75This micro-service provides a basic OPDS1 (XML/Atom) browser. See [opds.md](opds.md).
76
77## GET /opds-v2-browse/ and /opds-v2-browse/{ENCODED_URL}
78
79Same as above, for OPDS2 (JSON)
80
81## GET /opds-v1-v2-convert/ and /opds-v1-v2-convert/{ENCODED_URL}
82
83This micro-service loads an OPDS1 feed (XML/Atom), converts it to OPDS2 (JSON), and displays both in a browsable "compare" view.