Overview
This function downloads the book’s database files, applies patches if available, creates the necessary database tables, and exports the data to the specified format. The output can be either a JSON file or a SQLite database file.Function Signature
Parameters
number
required
The unique identifier of the book to download
DownloadBookOptions
required
Configuration options for downloading the book
Returns
string
The path of the created output file
Examples
Download as JSON
Download as SQLite Database
Using Pre-fetched Metadata
Download Multiple Books
Custom Writer for Browser
Output Format
SQLite Format
The SQLite database contains the following tables:pages- Book pages with contenttitles- Chapter/section titles with hierarchy
JSON Format
Patch Handling
The function automatically handles applying patches:
- If a minor release (patch) is available, it’s downloaded and applied
- Patches contain corrections and additions to the major release
- The final output includes all patched data
Error Handling
Performance Considerations
Configuration Requirements
Ensure the
booksEndpoint is configured before calling this function:Related Functions
- getBookMetadata - Fetch metadata before downloading
- getBook - Get book data as a JavaScript object without saving to disk
- getCoverUrl - Generate the cover image URL for a book