One request a second for the whole app, so our place search has no search-as-you-type
Setting up a business campaign in Nakodo means saying where to look. You type a town, a city, a region or a country, press Add, choose which match you meant, and pick a distance. To search a places listing by coordinates, we need to turn "Leeds" into a latitude, a longitude and a sensible radius. That is geocoding, and the paid options are fine and metered. We used Nominatim , OpenStreetMap's own…
When building a place search feature in Nakodo's business campaign, the interface must prioritize the policy over performance. The free and metered Nominatim geocoder is used for geocoding, but it enforces a strict limit of one request per second across the entire user base. To adhere to this policy, the interface is designed without search-as-you-type functionality.
Users type their input, press Add or Enter, and then select from the returned matches. This approach avoids performance compromises and aligns with the policy, even though it may seem like a design choice. The rate limiting is implemented using Upstash's Ratelimit library, with a constant key of "global" to represent the shared bucket for all users.
The limiter is configured to allow a maximum of one request per second. The caching mechanism is set to retain results for 30 days, as the location data is unlikely to change within that timeframe. If the rate limiter is unavailable, a local timestamp-based wait mechanism is employed to manage the request flow. The User-Agent string is dynamically generated, ensuring compliance with the policy's requirement for an identifying identifier.
This solution provides a user-friendly experience while respecting the Nominatim geocoding API's usage policy.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.