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.
The master database contains comprehensive information about all books, authors, and categories in the Shamela library.
Basic Download as SQLite
Download the master database as a SQLite file:
import { downloadMasterDatabase } from 'shamela';
const dbPath = await downloadMasterDatabase({
outputFile: { path: './shamela_master.db' }
});
console.log(`Downloaded to: ${dbPath}`);
Download as JSON
Export the master database as JSON for easier inspection:
import { downloadMasterDatabase } from 'shamela';
const jsonPath = await downloadMasterDatabase({
outputFile: { path: './shamela_master.json' }
});
console.log(`Downloaded to: ${jsonPath}`);
Optimize by pre-fetching metadata to avoid an extra HTTP call:
import { getMasterMetadata, downloadMasterDatabase } from 'shamela';
// Fetch metadata first
const metadata = await getMasterMetadata();
console.log(`Latest version: ${metadata.version}`);
console.log(`Download URL: ${metadata.url}`);
// Use metadata in download
await downloadMasterDatabase({
masterMetadata: metadata,
outputFile: { path: './master.db' }
});
Check for Updates
Check if there are updates available from a specific version:
import { getMasterMetadata } from 'shamela';
// Check for updates from version 5
const updates = await getMasterMetadata(5);
if (updates.version > 5) {
console.log(`New version available: ${updates.version}`);
console.log(`Download from: ${updates.url}`);
} else {
console.log('No updates available');
}
type GetMasterMetadataResponsePayload = {
url: string; // Download URL for the master database patch
version: number; // Latest version number
};
Example Response
{
"url": "https://shamela.ws/api/master_patch/download/123.zip",
"version": 42
}
The output format is automatically detected from the file extension:
import { downloadMasterDatabase } from 'shamela';
// SQLite format (.db or .sqlite)
await downloadMasterDatabase({
outputFile: { path: './master.db' } // SQLite
});
await downloadMasterDatabase({
outputFile: { path: './master.sqlite' } // SQLite
});
// JSON format
await downloadMasterDatabase({
outputFile: { path: './master.json' } // JSON
});
The library automatically validates that all required tables (books, authors, categories) are present in the downloaded master database.