惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
博客园 - 司徒正美
Last Week in AI
Last Week in AI
Recent Announcements
Recent Announcements
Y
Y Combinator Blog
博客园 - 聂微东
M
MIT News - Artificial intelligence
博客园_首页
Jina AI
Jina AI
博客园 - 叶小钗
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
Vercel News
Vercel News
The Cloudflare Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
云风的 BLOG
云风的 BLOG
N
Netflix TechBlog - Medium
B
Blog
Google DeepMind News
Google DeepMind News
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I Built a Global Location Data API with 12M+ Cities — Her...
Bosco Edwin · 2026-05-31 · via DEV Community

Every developer has hit this wall. You're building an app. You need a city search dropdown, or postal code validation, or timezone detection. Simple stuff. You look at Google Maps Platform pricing. You close the tab. That's why I built LocalityAPI.

The Problem With Existing Solutions
Google Maps Platform is comprehensive but expensive. $5 per 1,000 Place Autocomplete requests. $17 per 1,000 Geocoding requests. For a startup doing 100,000 requests per month that's $500-1,700 monthly just for location data. Before you've made a dollar.
Free alternatives exist but come with serious tradeoffs. GeoNames has the data but the API is unreliable and the documentation is from 2009. IP geolocation APIs give you approximate city from IP but can't search by name. Most 'free geocoding APIs' are wrappers around OpenStreetMap Nominatim with strict rate limits and no SLA.
Self-hosting is possible but means downloading and maintaining 100GB+ of planet data, setting up PostGIS, writing your own API layer, and hoping nothing breaks on a Sunday night. There had to be a better way.

What I Built
LocalityAPI is a REST API giving developers access to:
• 12M+ global places — cities, towns, villages, suburbs, hamlets across 248 countries
• 1.8M+ postal codes — covering 60+ countries with coordinates and admin regions
• IANA timezones — for every location
• Administrative hierarchy — countries → states/provinces → counties → cities
• Confidence scores — each record is cross-validated across multiple authoritative sources
Seven clean endpoints. One API key. Under 20ms response time.

The Technical Stack
Database: PostgreSQL 16 with PostGIS. The places table has 13.5 million records with spatial indexes for radius searches and full-text search indexes for city name queries.
Data pipeline: We import from multiple sources and cross-validate. Each record gets a confidence score from 1-3 depending on how many independent sources agree on the data. This is something no competitor does.
API layer: FastAPI with async PostgreSQL connections via asyncpg. Redis for caching frequent queries. Nginx as reverse proxy.

Response times in production:
Endpoint Response Time
/v1/search 50-150ms
/v1/autocomplete 10-20ms
/v1/postal 80-120ms
/v1/nearby 80-120ms
/v1/countries 5ms

The API Design Philosophy
Single header authentication. Pass X-API-Key: your_key on every request. No OAuth dance, no token refresh, no SDK required.
Consistent response shape. Every endpoint returns results, count and query_ms. You always know where your data is.
Honest about data quality. The confidence field (1-3) tells you how reliable a record is. Most APIs hide this. We surface it.
No forced pagination. For most use cases you want the top 10 results immediately. Add limit=50 if you need more.

Code Examples
Search a city (JavaScript):
const response = await fetch(
'https://api.localityapi.com/v1/search?q=Dubai&country=AE',
{ headers: { 'X-API-Key': 'your_key_here' } }
);
const data = await response.json();
// data.results[0].name → 'Dubai'
// data.results[0].timezone → 'Asia/Dubai'
// data.query_ms → 8

Postal code to coordinates (Python):
import requests

def postal_to_coords(code, country):
response = requests.get(
'https://api.localityapi.com/v1/postal',
params={'code': code, 'country': country},
headers={'X-API-Key': 'your_key_here'}
)
data = response.json()
return data['lat'], data['lng']
lat → 51.501, lng → -0.1247

Real Use Cases
• Address forms. Use /v1/countries for the country dropdown, /v1/admin for states/provinces, /v1/autocomplete for the city field. Three API calls, fully dynamic address form, no hardcoded lists to maintain.
• Timezone detection. User signs up and enters their city. One call to /v1/search returns their IANA timezone. All their notifications go out at the right local time.
• Shipping validation. E-commerce checkout enters postal code. One call to /v1/postal validates it exists and returns city and coordinates. Catch invalid postal codes before the order ships.
• Location-based filtering. User grants location permission, you get lat/lng, one call to /v1/nearby returns all cities within 50km. Filter your database by those cities.

Pricing
Free tier: 1,000 calls/day. No credit card required. Sign up and get a key in 30 seconds.
Paid plans start at $19/month for 50,000 calls/day. Compare that to Google's $500-1,700 for the same volume.

What's Coming
• Points of interest (restaurants, hotels, hospitals, landmarks)
• Reverse geocoding (lat/lng to full address)
• Street-level address search
• Administrative boundary polygons

Try It
Free tier at localityapi.com — no credit card, key in 30 seconds.
Full documentation at docs.localityapi.com

Questions? I read every email at support@localityapi.com

_If you found this useful, a like or share helps others find it. And if you build something with LocalityAPI, I'd love to hear about it in the comments.
_