EPUB Create, Read & Validate API
Build a valid EPUB 3 e-book from Markdown or HTML chapters with cover and TOC, or read an EPUB: metadata, TOC, chapter text and structure checks.
action=create (default with title) builds an EPUB 3 book: send chapters (array of {title, markdown | html}) or one markdown text split at # headings (split_level 2 for ##), plus authors, language (default vi), publisher, description, date, subjects, rights, identifier and an optional cover image (multipart field or cover_base64). The book has a nav document and an NCX for old readers, a cover page, landmarks, clean XHTML (scripts and unsafe tags removed, images given as data: URIs embedded), optional title page, toc_depth=2 for sections and embed_font=1 to embed Be Vietnam Pro for readers without Vietnamese fonts. The answer is the .epub file, or JSON with base64 when format=json.
action=read (default when a file is sent) returns the metadata (title, creators with roles, languages, identifiers, publisher, dates, subjects, series), the table of contents (nav or NCX), each spine item with title, word count and its content as text, markdown, html or none, the cover (base64 with include_cover=1) and structure issues. action=validate returns only the checks: mimetype first and stored, container.xml, package document, required metadata, manifest files present, spine references, navigation, XHTML namespace and HTML entities.
Everything runs in memory; files are not stored. The checks cover the common mistakes, not the full W3C EPUBCheck rule set. No conversion to MOBI or PDF.
Markdown · OpenAPI · Postman · llms.txt
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
action | body | string | no | create, read or validate (default: read when a file is sent, otherwise create). | |
file | body | file | no | read / validate: the EPUB file (multipart, raw body or file_base64). | |
content | body | string | no | text | read: text, markdown, html or none. |
title | body | string | no | create: book title (required). | |
chapters | body | array | no | create: [{title, markdown | html}]. | |
markdown | body | string | no | create: one Markdown text split into chapters at # headings. | |
authors | body | array | no | create: authors. | |
language | body | string | no | vi | create: BCP 47 language tag. |
cover | body | file | no | create: cover image (PNG / JPEG / GIF / WebP). | |
embed_font | body | boolean | no | create: embed Be Vietnam Pro. | |
format | body | string | no | epub | create: epub or json (base64). |
Example
curl -X POST "https://apibox.io.vn/v1/epub" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"title":"Truyện ngắn","authors":"Nguyễn Văn A","markdown":"# Chương 1\n\nXin chào.\n\n# Chương 2\n\nTạm biệt.","format":"json"}'const res = await fetch('https://apibox.io.vn/v1/epub', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"title": "Truyện ngắn",
"authors": "Nguyễn Văn A",
"markdown": "# Chương 1\n\nXin chào.\n\n# Chương 2\n\nTạm biệt.",
"format": "json"
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/epub",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"title": "Truyện ngắn", "authors": "Nguyễn Văn A", "markdown": "# Chương 1\n\nXin chào.\n\n# Chương 2\n\nTạm biệt.", "format": "json"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/epub');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"title":"Truyện ngắn","authors":"Nguyễn Văn A","markdown":"# Chương 1\\n\\nXin chào.\\n\\n# Chương 2\\n\\nTạm biệt.","format":"json"}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"filename": "Truyen-ngan.epub",
"bytes": 3165,
"identifier": "urn:uuid:00000000-0000-4000-8000-000000000001",
"chapters": [
{
"title": "Chương 1",
"href": "text/ch001.xhtml",
"sections": 0
},
{
"title": "Chương 2",
"href": "text/ch002.xhtml",
"sections": 0
}
],
"images": 0,
"words": 8,
"files": [
"mimetype",
"META-INF/container.xml",
"OEBPS/text/ch001.xhtml",
"OEBPS/text/ch002.xhtml",
"OEBPS/style.css",
"OEBPS/nav.xhtml",
"OEBPS/toc.ncx",
"OEBPS/content.opf"
],
"warnings": [],
"epub_base64": "UEsDBBQAAAAAAAA4IVxvYassFAAAABQAAAAIAAAA…"
}
Use cases
- Publish web novels or translated stories as EPUB for e-readers
- Extract chapter text from EPUB files for RAG or search
- Check an EPUB before uploading it to a store
- Generate e-books from a CMS or a Markdown repository
FAQ
Does it pass EPUBCheck?
The writer produces EPUB 3 with the required parts (stored mimetype, nav, NCX, dcterms:modified, unique identifier) and well-formed XHTML. Run W3C EPUBCheck for a full conformance report before publishing to a store.
Are remote images downloaded?
No. Readers do not load remote images, so they are removed with a warning; send images as data: URIs in the Markdown or HTML.
Can it read EPUB 2 files?
Yes. The reader uses the nav document of EPUB 3 or the NCX of EPUB 2 for the table of contents.
Related APIs
Image Metadata & EXIF
Read image dimensions, format, EXIF camera data, capture settings and GPS location from JPEG, PNG, WebP, HEIC, AVIF, GIF and more – upload or URL.
PDFPDF Metadata
Read PDF metadata: page count, title, author, creator, producer, dates, PDF version, encryption, form fields and the size of each page (A4, Letter…).
PDF₫Quote & Receipt PDF
Generate clean PDF quotations, receipts, orders and simple invoices from JSON, with Vietnamese text, VAT, totals in words and a VietQR code for payment.