apogeoapi — Python SDK
Official Python client for ApogeoAPI. IP geolocation, countries, cities, states, and exchange rates. Zero dependencies.
Installation
pip install apogeoapi
Requires Python ≥ 3.9. No third-party dependencies.
Quick start
from apogeoapi import ApogeoAPIClient
client = ApogeoAPIClient(api_key="your_key_here")
# Country info
country = client.get_country("DE")
print(country["name"]["common"]) # Germany
print(country["capital"]) # Berlin
print(country["currencies"]) # {"EUR": {...}}
# IP geolocation
geo = client.geolocate_ip("8.8.8.8")
print(geo["country"]["name"]) # United States
print(geo["city"]) # Mountain View
print(geo["timezone"]) # America/Los_Angeles
print(geo["isp"]) # Google LLC
# Exchange rate (relative to USD)
rate = client.get_currency_rate("EUR")
print(rate["usdRate"]) # e.g. 0.9214
# List all countries in a region
europe = client.list_countries(region="Europe")
print(len(europe)) # 44
# States/provinces
states = client.get_states("BR")
print(states[0]["name"]) # Acre
# Cities
cities = client.get_cities("MX", state="Jalisco", limit=5)
# Full-text search
results = client.search_countries("united")
# → [United States, United Kingdom, United Arab Emirates, ...]
# Global search (countries + cities + currencies)
all_results = client.global_search("paris")
API Reference
| Method | Description |
|---|---|
list_countries(region, subregion, limit, offset, fields) |
List all countries |
get_country(code, fields) |
Country by ISO2 or ISO3 code |
search_countries(query, limit) |
Search countries by name |
get_states(country_code) |
States/provinces for a country |
get_cities(country_code, state, limit, offset) |
Cities, optionally filtered by state |
geolocate_ip(ip) |
Geolocate IPv4 or IPv6 |
get_currency_rate(currency_code) |
USD exchange rate for a currency |
list_exchange_rates() |
All 161 supported currencies |
global_search(query, limit) |
Search across all data types |
Error handling
from apogeoapi import (
ApogeoAPIClient,
ApogeoAPIError,
ApogeoAPIAuthError,
ApogeoAPIRateLimitError,
)
try:
data = client.get_country("XX")
except ApogeoAPIAuthError:
print("Invalid API key — get one at https://apogeoapi.com")
except ApogeoAPIRateLimitError:
print("Rate limit hit — upgrade at https://apogeoapi.com/pricing")
except ApogeoAPIError as e:
print(f"API error {e.status_code}: {e}")
Get an API key
Sign up at apogeoapi.com. Free plan: 1,000 requests/month with a 14-day full-access trial on signup.
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
apogeoapi-1.0.0.tar.gz
(5.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file apogeoapi-1.0.0.tar.gz.
File metadata
- Download URL: apogeoapi-1.0.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f07824ba06d11330e0b33292a7721e8e4cc201d3e6cc5e653a7fcf5c769da455
|
|
| MD5 |
1a90e841a1dfd91cde61b3e2a406ccbe
|
|
| BLAKE2b-256 |
2307bd9e2a7ed54a34c243e10160b0ea2c6494942f98bd76e688afd72b32940e
|
File details
Details for the file apogeoapi-1.0.0-py3-none-any.whl.
File metadata
- Download URL: apogeoapi-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc9f98d07e936c3389fc85c8d5940748178ed1da86dc5e00669f0a3b3e78e550
|
|
| MD5 |
a1f54667dce64d72bdf7f6952b741fbd
|
|
| BLAKE2b-256 |
ed4500ca40feba3476c5eec43e11b6df813204bd60d0fdbe5eb16fb721bb17a2
|