LocalityAPI
Get API Key

Quick Start

Get up and running with LocalityAPI in just a few minutes.

1

Sign Up and Get Your API Key

Sign up at localityapi.com and get your free API key. No credit card required. Your key will look like:

plaintext
lapi_live_aBcDeFgHiJkLmNoPqRsTuVwXyZ123456
2

Make Your First Request

Try searching for a city using the Search endpoint:

bash
curl "https://api.localityapi.com/v1/search?q=Dubai&country=AE" \
  -H "X-API-Key: lapi_your_key_here"
3

Parse the Response

The API returns JSON with matching locations. Here's how to parse it in JavaScript:

javascript
const response = await fetch(
  'https://api.localityapi.com/v1/search?q=Dubai&country=AE',
  { headers: { 'X-API-Key': process.env.LOCALITY_API_KEY } }
);

const data = await response.json();

// Access the results
data.results.forEach(city => {
  console.log(`${city.name}, ${city.country_name}`);
  console.log(`Coordinates: ${city.lat}, ${city.lng}`);
  console.log(`Timezone: ${city.timezone}`);
  console.log(`Population: ${city.population.toLocaleString()}`);
});
4

Upgrade When Ready

The free plan includes 1,000 calls per day. When you need more, check out our pricing plans for higher limits and priority support.

You're All Set!

You've successfully made your first API call. Explore the API Reference to discover all available endpoints.

Complete Example

Request

bash
curl "https://api.localityapi.com/v1/search?q=Dubai&country=AE" \
  -H "X-API-Key: lapi_your_key_here"

Response

json
{
  "results": [
    {
      "id": 292223,
      "name": "Dubai",
      "country": "AE",
      "country_name": "United Arab Emirates",
      "admin1": "Dubai",
      "admin2": null,
      "lat": 25.2048,
      "lng": 55.2708,
      "timezone": "Asia/Dubai",
      "population": 3331420,
      "type": "city",
      "postal_code": "13014",
      "confidence": 3,
      "sources": ["osm", "geonames", "simplemaps"]
    }
  ],
  "count": 1,
  "query_ms": 8
}

Next Steps