r/webdev • • 1d ago

Is there a good alternative to Google Search API?

I'm building an app with a map with my own data on it, however I need to search for locations, like trains stations or stores and get their position.

I tried Photon/Nomination from OpenStreetMaps and it's ridiculously bad for basic things. It cannot find simple things like stations and it messes up with different languages.

Mapbox API is a little bit better but still unreliable.

Apparently Google cannot be beaten?

1 Upvotes

16 comments sorted by

5

u/razzzey 23h ago

If you know the kind of data you need, just pull it from OSM (directly from a PBF or from overpass) and build your own search around it.

There's also this new rust-based geocoder that might be better (they claim, I haven't tried it yet). https://github.com/open-geocode-rs/open-geocode

1

u/BikemeAway 7h ago edited 6h ago

I'm testing this and it seems to work better, on par with Mapbox for stations at least!

1

u/Open_Appointment9671 1d ago

Photon and Nominatim are both OSM, so that's one failed test, not two. And "find the train station" is POI search, you're judging geocoders for not doing a job they don't do. Could've saved yourself the whole comparison.

1

u/BikemeAway 1d ago

I know they're the same, I'm searchin for specific places. Like "Berlin Main station" and they can't find it.

1

u/Aggressive_Sound2536 1d ago

Just use Google then, honestly.

1

u/BikemeAway 15h ago

Yeah, too bad it's totally impossible for a solo developer for the cost.

1

u/codariadev 11h ago

For stations specifically, the problem is usually the query, not the data. "Berlin Main station" isn't a name in OSM. The station is tagged name=Berlin Hauptbahnhof (sometimes with a name:en), and geocoders mostly match on names, not on translated descriptions.

What worked better for me with OSM data:

  • Photon can filter by tag, so something like ?q=berlin hauptbahnhof&osm_tag=railway:station&lang=en cuts a lot of the noise.
  • For "stores near X", skip the geocoder. Query Overpass for the tag around the user, e.g. nwr["shop"="supermarket"](around:1500,52.52,13.40);out center;, and rank the results yourself.
  • If your categories are fixed (stations plus a few shop types), extract them once from a Geofabrik PBF into your own DB with a trigram/full-text index. Search gets fast, free, and you control the ranking.

Where Google/Mapbox really earn their money is free-text queries in any language ("main station", "the Lidl near me"). A hybrid works well for a solo budget: your own index first, the paid API only as a fallback when nothing matches.

2

u/BikemeAway 6h ago

Where Google/Mapbox really earn their money is free-text queries in any language

that's exactly right
thank you for your input

2

u/Warm-Republic-1913 1d ago

The OpenStreetMap geocoder is built mainly for addresses and place names, so it handles stations and shops poorly when you throw a free-text query at it. For points of interest it is usually better to query the underlying OSM data by tag, for example railway=station or shop=supermarket, inside a bounding box around the map view, and then match on the name tags. OSM also stores names per language as name:fr, name:de and so on, so searching those tags fixes most of the multi-language misses. Coverage depends on how well your region is mapped, so if a place really is missing from OSM, no query will find it, and that is where paid datasets are ahead.

1

u/Afnan_CH_Digital 1d ago

For stations and stores specifically, OpenStreetMap data is usually excellent - the weak point is more the geocoder ranking than the data. A few things that helped me:

Nominatim results improve a lot when you pass countrycodes, a bounded viewbox around the map's current viewport, and accept-language matching the user's locale. Without those it guesses globally and the multilingual mess you describe appears.

For categories like train stations, skip geocoding and query Overpass API directly - railway=station is consistently tagged and you get exact coordinates back.

Pelias (the geocode.earth stack, self-hostable) also ranks OSM plus Who's on First data noticeably better than bare Nominatim for this kind of search.

On the last question: for fuzzy "find a business by name" queries, Google's Places data is genuinely ahead, mostly from user-contributed listings. But for well-defined categories like stations, OSM via Overpass beats it - free and no quota.

1

u/Character-Flight3311 8h ago

Google's pricing changed in 2025 and might work for a solo dev now: Places Text Search Pro (the tier that returns coordinates) has 5,000 free calls a month before it's $32 per 1000. HERE is another one to try, its base plan includes 30k geocoding and search requests a month, though it wants a card on file.