Skip to content

Read an EPUB chapter as HTML

GET
/assets/{id}/epub/chapters/{idx}

Returns one chapter of an EPUB asset as a complete HTML document. idx is the chapter’s position from GET /assets/{id}/epub/spine, starting at 0.

The chapter file is parsed and written out again as HTML, so the markup can differ from the file in the book. Relative URLs in href, src and srcset attributes are rewritten to GET /assets/{id}/epub/resources/{path} URLs, links to other chapters included; absolute URLs, paths starting with / and # links are left as they are, and so are URLs in stylesheets and style attributes. Rewritten URLs for files below the top level of the archive don’t reach the resource route at the moment (see that page).

The HTML isn’t cleaned: scripts, event handlers and links to other sites stay in it. Show it in a sandboxed frame that doesn’t allow scripts.

You need to be signed in, and any account can read any EPUB asset. Each chapter is cached per asset and index and not refreshed, so a cached chapter can still be returned after the asset is deleted, for as long as its entry stays in the cache. A 404 means the asset or the chapter wasn’t found, including an idx below 0 or past the last chapter. An idx that isn’t a whole number gets a plain-text 400. Server errors usually get the JSON 500, but some get a plain-text 500.

id
required
string format: uuid

The id of the EPUB asset.

idx
required
integer

The chapter’s position in the reading order, starting at 0, as idx in the chapter list.

The chapter as an HTML document.

string format: binary

Authentication required, missing, or invalid

object
error
required

Human-readable error summary

string
Example
the request could not be completed
Example
{
"error": "authentication required: sign in and retry with a valid session or API token"
}

Resource not found

object
error
required

Human-readable error summary

string
Example
the request could not be completed

Unexpected server error

object
error
required

Human-readable error summary

string
Example
the request could not be completed