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
The version number to check for updates. Pass 0 (or omit) to get the latest version.
Returns
GetMasterMetadataResponsePayload
Master database metadata including download URL and version Download URL for the master database patch
Latest version number of the master database
Examples
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 );
}