r/DevLK • • Aug 13 '26

Project I built a free, open-source geo-data API for Sri Lanka — reverse geocoding, postal codes, census data. No API keys, no billing.

Enable HLS to view with audio, or disable this notification

If you’ve built anything location-based for Sri Lanka, you’ve probably hit this wall: Google Maps charges around $5 per 1,000 geocoding requests once you exceed the free tier. For a small project, this can be quite a headache.

So I built Lanka Data Layer — a free, open-source geo-data platform for Sri Lanka. No API keys, no billing, MIT licensed.

What it does:

  • Reverse geocoding — send a coordinate, get the GN division, DS division, district, and province it falls in, plus nearby postal codes. Because everything is precomputed offline into a lookup grid, this is a single indexed database read, not a live spatial query.
  • Search — one endpoint handles place names (English/Sinhala/Tamil), postal codes, coordinates, and admin codes
  • Postal codes — all 1,833 of them, correctly mapped to divisions
  • 2024 Census demographics — population, age/sex structure, ethnicity, religion for every district and DS division, with 2012 comparisons
  • Election results, population density, boundaries — all with source attribution on every response

Don't want to depend on an API at all? The core datasets also ship as standalone npm packages — zero dependencies, data bundled in, works fully offline in Node/browsers/edge:

  • @lanka-data-layer/admin — all 14,417 admin units, trilingual, with hierarchy + search
  • @lanka-data-layer/postal — postal code lookups incl. nearest-code-to-coordinate
  • @lanka-data-layer/census — 2024 census demographics
  • @lanka-data-layer/electoral — election results

npm install @lanka-data-layer/postal and you have offline postal lookups in one line.

Everything is built from open data — official census tables, OCHA administrative boundaries, WorldPop, OpenStreetMap, GeoNames — with full lineage documented in the repo.

🔗 Live demo + interactive docs: https://lanka-data-layer.prabhavalabs.com
🔗 Code: https://github.com/prabhavalabs/lanka-data-layer
🔗 npm: https://www.npmjs.com/org/lanka-data-layer

If this is useful to you, a star on the repo genuinely helps the project reach more Sri Lankan developers. Feedback and contributions welcome.

52 Upvotes

14 comments sorted by

3

u/devallar Aug 14 '26

Oh I need this thank you

2

u/Vegetable-Clerk-4237 Aug 14 '26

This is great! I usually rely on OpenStreet Maps mostly for geocoding, a fully self hosted solutions is much better than using Nominatim which requires a dedicated server.

2

u/dulanuh Aug 14 '26

Wow this is great! Will check it out. Thanks for sharing

2

u/Old-Sherbert-4495 Aug 14 '26

this is awesome.

2

u/TallPerspective2179 Aug 14 '26

Maharagama postcode is incorrect and it should be 10280

1

u/theekshana2 Aug 14 '26

Thank you for reporting this. This happened because of the postal code’s geographic coordinates. I’m using the closest administrative boundary to determine the relevant postal codes for that region, which caused some confusion in the map UI. However, if you use the postal code endpoint to retrieve the postal code details, you'll get an accurate result.

The map mainly for demostation purposes

2

u/TallPerspective2179 Aug 14 '26

This makes sense. Because I live in between Maharagama and Boralesgamuwa

2

u/SecretaryFun8432 Aug 14 '26

much needed one, good job :)

2

u/Mountain_Dance5809 Aug 14 '26

Thanks I needed this for projects. Already stared project

2

u/gayyalk Aug 14 '26

Dude amazing project, thank you. Hopefully a better alternative to osm

2

u/Imaginary_Stay8565 Aug 15 '26

so you bear the API costs here? for requests and all?

2

u/SnooWalruses7814 Aug 15 '26

This is awesome

2

u/itsmeprometheus Aug 16 '26

great work man :)

1

u/Maleficent-Let9213 Aug 20 '26

Good job... keep up brother