Skip to Content
Nextra 4.0 is released!
SdksMosque TypeScript SDK

Mosque TypeScript SDK

A TypeScript SDK for integrating with the Mosque API.

Installation

npm install @mosques/sdk

Usage

Initialization

import { MasjidSDK } from '@mosques/sdk'; const sdk = new MasjidSDK('your-api-key');

Methods

getMasjids(filter?: { city?: string; country?: string })

Retrieve a list of masjids.

const masjids = await sdk.getMasjids({ city: 'London' }); console.log(masjids);

getPrayerTimes(masjidId: string)

Get prayer times for a specific masjid.

const times = await sdk.getPrayerTimes('1'); console.log(times.fajr, times.jumaah_times);

createMasjid(masjid: Partial<Masjid>)

Add a new masjid.

const newMasjid = await sdk.createMasjid({ name: 'New Mosque', address: '123 Street', city: 'London', country: 'UK', latitude: 51.5, longitude: -0.1, timezone: 'Europe/London' });

Time Utilities

The SDK includes TimeUtils for timezone-aware calculations.

import { TimeUtils } from '@mosques/sdk'; // Get current time in masjid's timezone const now = TimeUtils.getCurrentTimeInZone('Europe/London'); // Get next prayer const next = TimeUtils.getNextPrayer(prayerTimes, 'Europe/London'); console.log(`Next prayer is: ${next}`); // Check if Jumu'ah is soon (within 1 hour) if (TimeUtils.isJumuahSoon(prayerTimes, 'Europe/London')) { console.log("Jumu'ah is starting soon!"); }
Last updated on