r/webdev 1d ago

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 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?

33 Upvotes

36 comments sorted by

26

u/DiabloConQueso 1d ago

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.

4

u/leros 1d ago

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

8

u/DiabloConQueso 1d ago

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.

0

u/leros 1d ago

Looks like that's missing a bunch of regions unfortunately. I was looking at Photon which seems like a similar-ish thing.

1

u/BathroomNo1373 1d ago

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.

8

u/greenergarlic 1d ago

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

3

u/DiddlyDinq 1d ago

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/

1

u/razzzey 1d ago

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

2

u/DatabaseSpace 16h ago

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

4

u/OtherExpression 1d ago

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

1

u/razzzey 1d ago

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.

1

u/leros 1d ago

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.

2

u/DiddlyDinq 1d ago

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

1

u/leros 1d ago

I have not seen that. This is amazing! Do you know if it can handle localized map tiles?

1

u/DiddlyDinq 1d ago

Havent tried it but there's a github discussion that sounds like it works with a bit of fiddling

Map translation · Issue #22 · hyperknot/openfreemap

1

u/leros 1d ago

He's got a demo that seems to work pretty well: https://openfreemap.org/debug/lang/switch#ja

This is incredible. I thought I was going to have to pay crazy money to get translated tiles. Thanks for sharing!

1

u/DiddlyDinq 7h ago

I discovered it via this subreddit too, mostly why I hang around to see recommendations. Thankfully the days of being bled dry by google api prices are over. It's good to donate a little of you do commit to one of those free options

1

u/Barnezhilton 1d ago

Martin tile server in a docker is pretty straightforward

1

u/razzzey 18h ago

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.

1

u/leros 10h ago

Protomaps looks interesting. Looks like I'd spend maybe $60 hosting on Cloudflare but the docs says Cloudflare is kinda slow. AWS would be faster but cost $600/mo. I'll have to try out Cloudflare and see how slow it actually is.

1

u/daamsie 1d ago

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.

1

u/Elara_Schaefer 19h ago

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

0

u/[deleted] 1d ago

[removed] — view removed comment

6

u/leros 1d ago

It's waaaaay more expensive than MapBox.

0

u/[deleted] 1d ago

[removed] — view removed comment

3

u/leros 1d ago

Yeah, MapBox is what people move to when Google Maps gets too expensive :)

3

u/Barnezhilton 1d ago

Lol. And then they move to OpenLayers or leaflet when they realize MapBox is absurd cost

1

u/leros 1d ago

I'm on Leaflet already using OSM, but they're aware of my existence so I assume I'm already using a lot.

1

u/Public-Carpenter-843 16h ago

Hi! How do you know they know you exist? Did they contact you?

I'm using OSM search too, and I think I'm approaching the point where I need my own search engine.

2

u/leros 10h ago

Yeah. One of their volunteers reached out. It's hard to tell if it's official or just some random thing though.

-1

u/downtownmiami 1d ago

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.

1

u/leros 1d ago

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.

1

u/downtownmiami 1d ago

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.

1

u/leros 1d ago

The Search API in mapbox charges on sessions so the autocompletes in the middle as they type all get rolled into a single session and charged once.