Skip to main content

BookData

Represents book content data including pages and title hierarchy.
type BookData = {
  pages: Page[];
  titles: Title[];
};
pages
Page[]
required
Array of pages in the book
titles
Title[]
required
Array of titles/chapters in the book

Page

Represents a page in a book with content and optional metadata.
type Page = {
  id: number;
  content: string;
  page?: number;
  part?: string;
  number?: string;
};
id
number
required
Unique identifier for the page
content
string
required
HTML content of the page
page
number
Page number reference
part
string
Part or volume identifier
number
string
Additional page numbering information

Title

Represents a title heading or chapter in a book.
type Title = {
  id: number;
  content: string;
  page: number;
  parent?: number;
};
id
number
required
Unique identifier for the title
content
string
required
HTML content of the title heading
page
number
required
Page number where this title appears
parent
number
Parent title ID for hierarchical navigation

Usage 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);
  • MasterData - Master database structure with all books, authors, and categories
  • ShamelaConfig - Library configuration options