#What this API does
Send structured book content (metadata + chapters) and receive a valid EPUB 3.0 file with automatic table of contents, cover page, copyright page, and template-based styling. The output is reflowable — readers can adjust font size and layout on any device. Supports 21+ languages with auto-translated section headings.
#Endpoint
#POST https://api.yeb.to/v1/ebooks/epub/convert-from-file
- Best for: Converting novels, articles, manuals, or any multi-chapter content into EPUB ebooks.
- How it works: Pure PHP generation via ZipArchive — no external tools needed. XHTML chapters, OPF metadata, NCX + nav.xhtml TOC.
- Output format: Valid EPUB 3.0 with NCX fallback for EPUB 2 readers.
- Processing time: ~5-50ms depending on chapter count and cover image download.
#Quick start
Step 1: Create a JSON file with your book data:
{
"template": "elegant-novel",
"metadata": {
"title": "My Book",
"author": "Jane Doe",
"language": "en",
"description": "A wonderful story.",
"cover_image": "https://example.com/cover.jpg"
},
"chapters": [
{
"title": "Chapter 1",
"subtitle": "The Beginning",
"content": "It was a dark and stormy night...\n\nThe wind howled through the trees."
},
{
"title": "Chapter 2",
"content": "The next morning brought sunshine and hope."
}
]
}
Step 2: Upload to your server and call the API:
curl -X POST https://api.yeb.to/v1/ebooks/epub/convert-from-file \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"file_url": "https://yourdomain.com/book.json"}'
Step 3: Download the EPUB from the returned URL:
{
"success": true,
"epub_url": "https://yeb.to/storage/ebooks/epub/epub_abc123.epub",
"epub_size": 5772,
"template": "elegant-novel",
"chapters": 2
}
#Available templates
| Template | Style | Best for |
|---|---|---|
modern-novel | Serif, drop-cap first letters, contemporary | Fiction, novels, short stories |
elegant-novel | Palatino serif, italic chapters, bordered headings | Fiction, novels, multilingual |
academic-paper | Times, bold headings, left-aligned, clean | Research, academic, thesis |
business-report | Sans-serif, blue accent borders, corporate | Reports, proposals, white papers |
cookbook | Serif, warm red accents, recipe-friendly | Recipes, cooking, food |
travel-guide | Verdana, green accents, compact | Travel guides, tourism |
technical-manual | Sans-serif, shaded headers, monospace numbers | Documentation, manuals |
#Multilingual support
Set metadata.language to a 2-letter ISO code and the EPUB will automatically use
translated text for section headings:
- Table of Contents heading (e.g., "Съдържание" for Bulgarian)
- Chapter numbering format (e.g., "Глава {n}" for Bulgarian)
- Copyright text (e.g., "© {year} {author}. Всички права запазени.")
Supported: en, bg, de, fr, es,
it, pt, ru, uk, pl, nl,
tr, ja, zh, ko, ar, cs,
ro, el, sr, hr.
#Generated EPUB structure
book.epub (ZIP archive)
├── mimetype # "application/epub+zip" (uncompressed)
├── META-INF/
│ └── container.xml # Points to content.opf
└── OEBPS/
├── content.opf # Package document (metadata + manifest + spine)
├── toc.ncx # NCX table of contents (EPUB 2 compat)
├── nav.xhtml # EPUB 3 navigation document
├── style.css # Template-based stylesheet
├── cover.xhtml # Cover page (if cover_image provided)
├── titlepage.xhtml # Title page
├── copyright.xhtml # Copyright page
├── chapter_001.xhtml # Chapter 1
├── chapter_002.xhtml # Chapter 2
├── ...
└── images/
└── cover.jpg # Embedded cover image
#When to use EPUB vs PDF
| Feature | EPUB | |
|---|---|---|
| Reflowable text | Yes | Fixed layout |
| Reader font control | Yes | No |
| E-ink devices (Kindle) | Ideal | Usable |
| Print-ready | No | Yes |
| Fixed page numbers | No | Yes |
| Generation speed | ~5-50ms | ~2-5 seconds |
| File size | Small (5-50KB) | Larger (500KB-5MB) |