Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ragaeeb/shamela/llms.txt

Use this file to discover all available pages before exploring further.

Function Signature

getBook(id: number): Promise<BookData>

Description

Retrieves complete book data including pages and titles as a structured JavaScript object. This is a convenience function that downloads a book’s data and returns it directly. The function handles the temporary database creation and cleanup automatically.

Parameters

id
number
required
The unique identifier of the book to retrieve

Returns

Returns a Promise that resolves to a BookData object:
pages
Page[]
required
Array of pages in the book
titles
Title[]
required
Array of title entries (table of contents)

Example

import { getBook } from 'shamela';

const book = await getBook(26592);

console.log(`Book has ${book.pages.length} pages`);

// Display table of contents
book.titles?.forEach(title => {
  console.log(`${title.id}: ${title.content} (Page ${title.page})`);
});

// Access page content
const firstPage = book.pages[0];
console.log(firstPage.content.substring(0, 100));

Error Handling

Throws an error when:
  • Download fails
  • File operations fail
  • JSON parsing fails
  • Book ID does not exist

Build docs developers (and LLMs) love