ORIGINAL REDDIT POST

Cheaper alternatives to MapBox Search API

I run a free service which has a map on the website. I've got a location auto complete powered by MapBox. At my current scale, I'm spending $150/mo on that location search box. It looks like long term, hosting a Photon server myself might be the best option…

Original postr/webdev

I run a free service which has a map on the website. I've got a location auto complete powered by MapBox. At my current scale, I'm spending $150/mo on that location search box. It looks like long term, hosting a Photon server myself might be the best option as I keep scaling, but that's going to cost me $300/mo on Hetzner plus require management. In the meantime, any suggestions for cheaper location autocomplete services?

Collected discussion

22 comments

u/DiabloConQueso

What's your level of proficiency? What kind of hosting do you require? Space limitations? What geographies do you need autocomplete for? Because docker pull pelias/openaddresses is 100% free and can do exactly that.

u/lerosOP

The reason I don't cache is that the MapBox API tweaks the API results based on the user's location, which is pretty handy. I could disable that and do that sort of caching.

u/lerosOP

I'm extremely technical, so I can do whatever. I need global, including Korea and Japan but not China.

u/DiabloConQueso

https://github.com/pelias/docker/tree/master/projects Pelias can import the whole globe and has several options for different sources aggregated into one database: OpenAddresses, OpenStreetMap, etc. so that your coverage gaps are minimized. Would take a while to import depending on your compute resources, but at the end of it all, you'd have a 100% free and unlimited source to geocode, reverse geocode, and autocomplete addresses.

u/downtownmiami

Or a longer debounce on fetching until the user has entered more info for less refetches as the input changes …all I’m saying is there’s more than one way to skin a cat.

u/razzzey

This one actually needs much more storage for the whole world than Photon alone (at least ~1.5tb last I checked).

u/lerosOP

It's waaaaay more expensive than MapBox.

u/[deleted]

This comment was deleted.

u/lerosOP

I am going to eventually have to host my own tile server too, which looks like a whole beast. I priced out MapBox and it was going to be thousands.

u/DiddlyDinq

Check out the link below for tile servers, completely free, no limits or you can self host. I went from mapbox to it a while ago OpenFreeMap

u/DatabaseSpace

I think you can download parts possibly, this is the one I got to work. Can run it for free.

u/greenergarlic

Consider moving off of autocomplete, and instead do address matching after the user has already submitted. The user can then choose to use the suggested address, or their original address. Mapbox has a geocoding API to do this, free up to 100k requests per month. There are many other cheap services for this as well, including official ones from USPS and the census bureau

u/BathroomNo1373

What are you using for the frontend map, Leaflet? If you're already in that ecosystem the switch is way less painful than it seems. I did similar migration few months ago and the docker setup was actually smooth, just needed some patience with the initial data import.

u/Barnezhilton

Martin tile server in a docker is pretty straightforward

u/razzzey

You might be able to get away with 2 auction servers on Hetzner with 500gb nvme ssd's or something for less than that and host Photon, I think it requires about 100gb for the whole planet so 500gb would be more than enough. Put a load balancer and a cache in front and it should last you a long while. For hosted services, Maptiler is also a solution or Geocode earth (these are the people behind Pelias) but I haven't compared prices.

u/razzzey

As the other guy said, OpenFreeMap is good. There's also https://protomaps.com/ You can also use Martin to host tiles yourself. You can use one of the above services for the whole world and use Martin for the localized tiles you mentioned. You can also connect Martin to a Postgres database so you can dynamically serve whatever you want.

u/DiddlyDinq

Try Nominatim by OSM. I use it for town name to lat-lon and the inverse operation. Depends on your use case. https://nominatim.openstreetmap.org/

u/OtherExpression

MapLibre. Run your own tile server and you can have very low fixed cost. You can use maptiler for that

u/daamsie

Stadia Maps is the best balance of affordability and quality I've found - both for basemaps and for autocomplete. I use Maplibre-gl I ended up also writing my own autocomplete that takes care of all city/town related places (~4m) and then falling back to Stadia when it's address level search. It runs in its own Docker image and costs me a few dollars a month + a little extra at Stadia for the overflow queries.

u/Elara_Schaefer

If you need solid coverage for Korea and Japan specifically, Nominatim (the geocoder behind OpenStreetMap) actually handles both regions well because both countries have excellent OSM data coverage. Korea\s

u/downtownmiami

This sounds like you’ve architected zero cache rules for this system you’re describing. That’s far too expensive for a simple address input auto complete component. Prompt an LLM to optimize the system design of your data fetching to help lower your costs and possibly switch to a different solution in MapBox. This is like API design 101 stuff, so if you’re using Claude code set the output style setting to “Explanatory” or even “Learning” so you can get better with this sort of stuff.

u/[deleted]

This comment was deleted.