"Events near me" and "events in {city}" are two different features that both start from the same input: a city. Resolving that input to a real city with coordinates lets you support both — an exact-city filter for the search page, and a radius query (using the resolved city's latitude/longitude) for "near me" without asking for the visitor's location permission first.
Type a Brazilian city — same free endpoint, any of the 60 launch countries works the same way:
Resolve the picked city, then find nearby cities for a "also happening near {city}" widget:
async function nearbyEvents(cityId) {
const city = await fetch(`https://geomelon.p.rapidapi.com/cities/${cityId}`, {
headers: {
'x-rapidapi-host': 'geomelon.p.rapidapi.com',
'x-rapidapi-key': 'YOUR_API_KEY',
},
}).then((r) => r.json());
const nearby = await fetch(
`https://geomelon.p.rapidapi.com/cities/byCoordinates/closest?lat=${city.latitude}&lon=${city.longitude}`,
{
headers: {
'x-rapidapi-host': 'geomelon.p.rapidapi.com',
'x-rapidapi-key': 'YOUR_API_KEY',
},
},
).then((r) => r.json());
return nearby; // feed these city names/IDs into your own events query
}The event query itself (which events are actually happening) stays in your own database — Geomelon resolves the city and its neighbors, you filter your events table by the resulting city IDs.