Earth API Documentation

Quick Jump

🌍 About Earth API

Earth API provides comprehensive geographic and location data including countries, states, cities, and IP geolocation services.

βœ“ 250+ Countries with ISO codes
βœ“ 5,000+ States/Provinces
βœ“ 150,000+ Cities worldwide
βœ“ IP Geolocation services

How to Use the OpenAPI Spec

The downloaded OpenAPI JSON specification contains complete documentation of our Earth API. Use it with various tools and LLMs for integration, testing, and development.

1
LLM Integration (ChatGPT, Claude, etc.)

πŸ“€ Upload to LLM:

  1. β€’ Open ChatGPT, Claude, or your preferred LLM
  2. β€’ Upload the downloaded JSON file
  3. β€’ Ask: "Help me integrate with this API"

Example Prompts:

  • β€’ "Generate Python code to get country data"
  • β€’ "Create a JavaScript client for IP lookup"
  • β€’ "Show me the authentication requirements"

2
Development Tools

πŸ› οΈ Code Generation:

  • β€’ Swagger Codegen: Generate client SDKs
  • β€’ OpenAPI Generator: Create API clients
  • β€’ Postman: Import for testing

Quick Commands:

# Generate Python client
openapi-generator-cli generate \
  -i earth-api-docs.json \
  -g python \
  -o ./earth-api-client

πŸ“‹ Step-by-Step Usage Guide

1
Download & Save the Spec
  • β€’ Click "Download For LLM" button above
  • β€’ Save the earth-api-docs-YYYY-MM-DD.json file
  • β€’ Keep it accessible for your tools
2
Choose Your Integration Method

For LLMs:

Upload directly to get instant help

For Development:

Import into your IDE or tools

3
Get Your API Key

πŸ”‘ Remember: You'll need an API key from your Dashboard to make actual API calls.

4
Start Building
  • β€’ Use the spec to understand endpoints and parameters
  • β€’ Generate client code or make manual requests
  • β€’ Test with your API key in the Authorization header
  • β€’ Refer back to this documentation for examples

πŸ”§ Popular Tools That Support OpenAPI

Testing Tools
  • β€’ Postman
  • β€’ Insomnia
  • β€’ Thunder Client (VS Code)
  • β€’ Swagger UI
Code Generation
  • β€’ OpenAPI Generator
  • β€’ Swagger Codegen
  • β€’ NSwag Studio
  • β€’ AutoRest
AI Assistants
  • β€’ ChatGPT
  • β€’ Claude
  • β€’ GitHub Copilot
  • β€’ Cursor AI
πŸ’‘ Pro Tips
  • β€’ The spec includes all endpoint details, parameters, and response schemas
  • β€’ Look for "x-tier-required" in the spec to understand tier requirements
  • β€’ Rate limiting information is included in the response headers section
  • β€’ Use the examples in the spec as starting points for your requests

Download Options

Earth API Base URL: 
Public Endpoints: 

🎯 API Tiers & Rate Limits

Free Tier Countries, States, Cities basic info - Free, Paid, Premium access
Advanced Tier Search, IP lookup, coordinates - Paid, Premium access
Premium Tier Full hierarchy, analytics, batch operations - Premium only
Public Endpoints No authentication required - Very limited rate (5 req/min)

🌍 Free Tier Endpoints

Free, Paid, Premium

πŸ“‹ List All Countries API Endpoint

Retrieve a comprehensive list of all countries worldwide with ISO codes, phone codes, and optional pagination for states and cities. Perfect for populating country dropdown menus, building location selectors, or creating geographic databases for e-commerce applications.

Use Case Example: An e-commerce website needs to populate a country selection dropdown during checkout. This endpoint provides all 195+ countries with ISO codes for address validation and shipping calculations.

List countries

GET
β–Ί

Parameters

Required (path parameters)
Optional (query parameters)

cURL Command


                

πŸ” Get Country Details by ID

Fetch detailed information about a specific country using its unique database ID. Returns comprehensive country data including ISO codes, phone codes, currency information, and optionally nested states and cities data with pagination support.

Use Case Example: A travel booking platform stores country IDs in user profiles. When displaying trip recommendations, they use this endpoint to fetch complete country details and associated cities for destination suggestions.

Get country by ID

GET
β–Ί

Parameters

Required (path parameters)
Optional (query parameters)

cURL Command


                

🌐 Country Lookup by ISO2 Code

Retrieve country information using standard 2-letter ISO country codes (ISO 3166-1 alpha-2). Essential for international applications that need to convert country codes to full country data, validate addresses, or display localized content based on country codes.

Use Case Example: A payment processor receives "US" as a country code from credit card data and needs to validate the full country name, get the phone code (+1), and determine tax regulations for the United States.

Get country by ISO2 code

GET
β–Ί

Parameters

Required (path parameters)
Optional (query parameters)

cURL Command


                

πŸ—ΊοΈ Country Data by ISO3 Code

Access comprehensive country information using 3-letter ISO codes (ISO 3166-1 alpha-3). Ideal for applications working with international standards, banking systems, or government databases that commonly use 3-letter country codes for official documentation and data exchange.

Use Case Example: An international banking application processes SWIFT messages containing "USA" country codes and needs to convert them to full country details for compliance reporting and customer address verification.

Get country by ISO3 code

GET
β–Ί

Parameters

Required (path parameters)
Optional (query parameters)

cURL Command


                

πŸ›οΈ Get States and Provinces by Country

Retrieve all states, provinces, or administrative divisions for a specific country. Essential for address forms, shipping calculators, and location-based services that need accurate administrative boundaries. Supports pagination and optional city data for each state.

Use Case Example: A real estate website allows users to browse properties by state. When a user selects "United States," this endpoint provides all 50 states plus DC for property filtering and location-based search functionality.

States by country

GET
β–Ί

Parameters

Required (path parameters)
Optional (query parameters)

cURL Command


                

πŸ™οΈ Find State Information by City

Discover which state or province a specific city belongs to. Perfect for address validation, reverse geocoding, or when you have city information but need to determine the correct administrative division for shipping, taxation, or legal compliance purposes.

Use Case Example: A logistics company receives a shipping address with only the city "Chicago" and needs to automatically determine it's in Illinois state for accurate shipping calculations and delivery routing optimization.

State by city

GET
β–Ί

Parameters

Required (path parameters)
Optional (query parameters)

cURL Command


                

πŸ—³οΈ State Details by Database ID

Get comprehensive information about a specific state or province using its unique database identifier. Includes state name, country relationship, and optionally all cities within that state with pagination support for large datasets.

Use Case Example: A job board platform stores state IDs for job locations. When displaying job details, they use this endpoint to show the complete state information and nearby cities for job seekers looking for opportunities in that region.

Get state by ID

GET
β–Ί

Parameters

Required (path parameters)
Optional (query parameters)

cURL Command


                

πŸ“œ Complete Global States Directory

Access a comprehensive directory of all states, provinces, and administrative divisions worldwide. With over 5,000 states across 195+ countries, this endpoint is perfect for building complete geographic databases, data analysis, or comprehensive location selectors.

Use Case Example: A global weather service needs to create a complete database of all administrative regions worldwide for accurate weather reporting and location-based weather alerts across different states and provinces.

List all states

GET
β–Ί

Parameters

Required (path parameters)
Optional (query parameters)

cURL Command


                

🏘️ Cities Directory by Country

Retrieve all cities within a specific country with pagination support. Essential for travel applications, delivery services, or any platform requiring comprehensive city listings for address validation, location selection, or geographic analysis within country boundaries.

Use Case Example: A food delivery app expanding to Canada needs all Canadian cities to determine service areas, set up delivery zones, and calculate shipping costs for different municipal regions across the country.

Cities by country

GET
β–Ί

Parameters

Required (path parameters)
Optional (query parameters)

cURL Command


                

πŸŒ† Cities Within State or Province

Get all cities within a specific state or province. Perfect for regional business directories, local service platforms, or applications that need precise city-level data within administrative boundaries for targeted marketing or service delivery.

Use Case Example: A regional marketing agency targeting California businesses needs all cities in California to create location-specific advertising campaigns and analyze market penetration across different metropolitan areas.

Cities by state

GET
β–Ί

Parameters

Required (path parameters)
Optional (query parameters)

cURL Command


                

🌍 Global Cities Database

Access our complete database of 150,000+ cities worldwide with pagination support. Ideal for building comprehensive location databases, global business directories, or any application requiring complete geographic coverage for international operations and data analysis.

Use Case Example: A global logistics company needs to build a complete database of all cities worldwide for their shipping calculator, route optimization, and international delivery network planning across multiple continents.

List all cities

GET
β–Ί

Parameters

Required (path parameters)
Optional (query parameters)

cURL Command


                

⭐ Premium Tier Endpoints

Premium Only

🌍 Complete Country Hierarchy API

Get comprehensive country data including all states, cities, coordinates, translations, timezones, and hierarchical relationships in a single request. Perfect for building complete geographic databases, data synchronization, or applications requiring full country context without multiple API calls.

Use Case Example: A global business intelligence platform needs complete data for the United States including all 50 states, major cities, timezones, and translations for international reporting dashboards in multiple languages.

Get full country hierarchy

GET
β–Ί

Parameters

Required (path parameters)
Optional (query parameters)

cURL Command


                

πŸ“Š Geographic Analytics & Insights

Advanced analytics providing insights into geographic data usage patterns, popular locations, search trends, and geographic distribution statistics. Essential for business intelligence, market analysis, and understanding global user behavior patterns in your applications.

Use Case Example: A marketing agency uses location insights to identify trending cities for client campaigns, analyzing which geographic locations are most searched and have highest user engagement for targeted advertising strategies.

Location insights

GET
β–Ί

cURL Command


                

πŸ—ΊοΈ Precision State Location by Coordinates

Find states and provinces within a specified radius of geographic coordinates with high precision. Ideal for mobile applications, GPS services, regional analysis, and location-based notifications requiring state-level accuracy with coordinate-based proximity search.

Use Case Example: A weather alert system at coordinates near state borders uses this endpoint to identify all affected states within a 50km radius for accurate severe weather warnings and emergency notifications.

States by coordinates

GET
β–Ί

Parameters

Required (path parameters)
Optional (query parameters)

cURL Command


                

πŸ™οΈ Proximity-Based City Discovery

Discover cities within a customizable radius of any geographic coordinates. Perfect for "nearby cities" features, local business discovery, travel recommendations, delivery radius calculations, and location-based services requiring precise city-level proximity data.

Use Case Example: A rideshare app uses coordinates 40.7128Β°N, 74.0060Β°W to find all cities within 25km of New York City for expanded service area mapping and driver allocation optimization across the metropolitan region.

Cities by coordinates

GET
β–Ί

Parameters

Required (path parameters)
Optional (query parameters)

cURL Command


                

⚑ High-Performance Batch IP Geolocation

Process up to 100 IP addresses simultaneously with enterprise-grade performance and accuracy. Essential for log analysis, fraud detection, bulk data processing, security audits, and applications requiring high-throughput IP geolocation with optimized response times.

Use Case Example: A cybersecurity platform analyzes server logs containing 1000+ IP addresses by batching them into groups of 100, quickly identifying attack origins and geographic threat patterns for security response automation.

Batch IP lookup

POST
β–Ί

Request Body

{"ips":["8.8.8.8","1.1.1.1"]}

cURL Command


                

πŸ“œ IP Geolocation History & Audit Trail

Access complete history of all IP geolocation lookups with timestamps, results, and search patterns. Perfect for compliance reporting, usage auditing, security analysis, and understanding geographic access patterns with comprehensive search and filtering capabilities.

Use Case Example: A financial services company reviews IP lookup history to demonstrate compliance with geographic restrictions, showing audit trails of location verification for international transaction monitoring.

IP lookup history

GET
β–Ί

Parameters

Required (path parameters)
Optional (query parameters)

cURL Command


                

πŸ“ˆ Advanced API Usage Analytics Dashboard

Comprehensive analytics including request patterns, response times, error rates, geographic usage distribution, peak usage hours, and performance metrics. Essential for API optimization, capacity planning, usage monitoring, and understanding application performance trends.

Use Case Example: A SaaS platform monitors API usage analytics to identify peak traffic hours, optimize server scaling, track geographic distribution of users, and plan infrastructure improvements based on detailed performance metrics.

Usage analytics

GET
β–Ί

Parameters

Required (path parameters)
Optional (query parameters)

cURL Command


                

πŸ‘€ Account Management

All Tiers

πŸ“Š Real-Time Account Usage Statistics

Monitor your API usage in real-time including request counts, rate limit status, subscription tier information, remaining quota, and billing period details. Essential for usage monitoring, cost control, and ensuring optimal API utilization within your plan limits.

Use Case Example: A development team monitors their account usage daily to track API consumption against their premium tier limits, receiving alerts when approaching monthly quotas to prevent service interruptions.

Account usage stats

GET
β–Ί

cURL Command


                

🌐 Public Endpoints

No Auth Required

🌍 Global Countries Database Statistics

Get the total count of countries available in our database without authentication. Perfect for displaying database statistics, validating API connectivity, or building dynamic content that references our geographic coverage with up-to-date country counts.

Countries count

GET
β–Ί

cURL Command


                

⚑ API Health & Status Monitor

Check real-time API health, response times, and service availability without authentication. Essential for monitoring integrations, status page widgets, uptime monitoring, and ensuring API availability before making authenticated requests in production environments.

API status

GET
β–Ί

cURL Command


                

ℹ️ API Version & Information Service

Retrieve comprehensive API information including version details, supported features, rate limits, and service capabilities without authentication. Perfect for API discovery, version compatibility checks, and displaying service information in developer dashboards or documentation.

Use Case Example: A developer integration wizard automatically checks API info to verify version compatibility, display available features, and configure appropriate rate limiting based on the current API capabilities and specifications.

API information

GET
β–Ί

cURL Command


                

πŸš€ Quick Start Examples

Get all US states:

GET /earth/v1/country/iso2/US?paginate_states=true

Search for cities named "Paris":

GET /earth/v1/cities/search?q=paris

IP Geolocation lookup:

GET /earth/v1/ip/lookup/8.8.8.8

Get API status (public):

GET /earth/v1/public/status

🌍 Earth API v1.0 - Comprehensive geographic and location data services. Use the parameter controls above each section to customize requests before testing.