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

Master(): Promise<MasterData>

Description

Retrieves the complete master dataset as a JavaScript object, including version information. The master database contains comprehensive information about all books, authors, and categories available in the Shamela library. This convenience function downloads the master database archive, builds an in-memory SQLite database, and returns structured data for immediate consumption alongside the version number of the snapshot.

Parameters

This function takes no parameters.

Returns

Returns a Promise that resolves to a MasterData object:
authors
Author[]
required
Array of all authors in the Shamela library
books
Book[]
required
Array of all books in the Shamela library
categories
Category[]
required
Array of all categories in the Shamela library
version
number
required
Version number for the downloaded master database

Example

import { getMaster } from 'shamela';

const master = await getMaster();

console.log(`Master database version: ${master.version}`);
console.log(`Total books: ${master.books.length}`);
console.log(`Total authors: ${master.authors.length}`);
console.log(`Total categories: ${master.categories.length}`);

// Find books by a specific author
const authorId = '123';
const booksByAuthor = master.books.filter(book => 
  book.author.split(',').includes(authorId)
);

console.log(`Books by author ${authorId}: ${booksByAuthor.length}`);

Error Handling

Throws an error when:
  • Download fails
  • Expected tables are missing from the master database
  • Database operations fail
  • Network request fails

Build docs developers (and LLMs) love