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.

Overview

The master database contains information about all books, authors, and categories in the Shamela library. This function fetches the download URL and version information for the master database patches.

Function Signature

getMasterMetadata(version?: number): Promise<GetMasterMetadataResponsePayload>

Parameters

version
number
default:"0"
The version number to check for updates. Pass 0 (or omit) to get the latest version.

Returns

GetMasterMetadataResponsePayload
object
Master database metadata including download URL and version

Examples

Get Latest Metadata

import { getMasterMetadata } from 'shamela';

const metadata = await getMasterMetadata();
console.log(metadata.url);     // URL to download master database patch
console.log(metadata.version); // Latest version number

Check for Updates

const currentVersion = 5;
const updates = await getMasterMetadata(currentVersion);

if (updates.version > currentVersion) {
  console.log(`Update available: ${updates.version}`);
  console.log(`Download from: ${updates.url}`);
}

Error Handling

This function throws an error when:
  • Required environment variables are not set
  • API request fails
  • Network connection issues occur
try {
  const metadata = await getMasterMetadata();
} catch (error) {
  console.error('Failed to fetch master metadata:', error.message);
}

Build docs developers (and LLMs) love