Repository navigation
FindNearestMosques
Zubir Jamal edited this page Jul 4, 2026
·
4 revisions
Finds verified masjids and suraus within a given radius of a location, sorted by distance, with ready-to-use navigation deep links for Google Maps and Waze.
| Parameter | Type | Required | Description |
|---|---|---|---|
location_name |
string | Optional* | Plain-text location, e.g. "Kajang, Selangor"
|
latitude |
number | Optional* | GPS latitude coordinate |
longitude |
number | Optional* | GPS longitude coordinate |
distance_km |
integer | Optional | Search radius in kilometres. Defaults to 5. |
*Provide either
location_nameor alatitude/longitudepair.
Returns a list of mosque objects sorted by distance (nearest first).
| Field | Type | Description |
|---|---|---|
name |
string | Official mosque or surau name |
distance_km |
number | Distance from the query location (km) |
coordinates |
object |
{ latitude, longitude } of the mosque |
google_maps_link |
string | Direct Google Maps URL |
waze_link |
string | Direct Waze deep link with auto-navigate enabled |
[
{
"name": "MASJID JAMEK PEKAN KAJANG",
"distance_km": 0.21,
"coordinates": { "latitude": 2.997541, "longitude": 101.788168 },
"google_maps_link": "https://maps.google.com/?q=2.997541,101.788168",
"waze_link": "https://waze.com/ul?ll=2.997541,101.788168&navigate=yes&z=10"
},
{
"name": "MASJID HJ. MAT SAMAN",
"distance_km": 1.89,
"coordinates": { "latitude": 2.984102, "longitude": 101.796345 },
"google_maps_link": "https://maps.google.com/?q=2.984102,101.796345",
"waze_link": "https://waze.com/ul?ll=2.984102,101.796345&navigate=yes&z=10"
}
]- Results include both **masjids ** and **surau **.
- Waze links use
navigate=yes— tapping the link will immediately start turn-by-turn navigation. - For real-time location queries (e.g. "near me"), pass GPS coordinates directly for the most accurate results.
"Find the nearest surau to KLCC." "Which mosque is closest to KLIA right now?" "I'm at Mid Valley, find me a masjid within 3km." "Where's the nearest mosque in Putrajaya?"
-
get_monthly_prayer_times— pair with mosque finder to know both where to go and when to be there -
get_current_time— check current time to see which prayer is approaching
All errors are returned as a structured JSON object with a single error field.
{ "error": "<human-readable message>" }| Scenario | Error Message |
|---|---|
| No location provided | "Provide either a location_name string or latitude/longitude coordinates." |
| Location name cannot be resolved | "Location '<name>' could not be resolved. Try a different name or use coordinates." |
| OpenStreetMap geocoding unreachable | "Location lookup failed: could not reach or parse OpenStreetMap data. Try again later." |
| General network failure | "Network error while searching for mosques. Please try again later." |