REST API Documentation
Complete API reference for countries, cities, rankings and search endpoints. Code examples in JavaScript and Python. Authentication, rate limits. Free tier available.
Base URL
https://bamwor.com/api/v1Authentication
Include your API key in every request using one of these methods:
X-API-Key: bw_live_your_key_here
# or
Authorization: Bearer bw_live_your_key_hereAnonymous requests (no key) are allowed with lower limits: 10/min, 100/day.
Anonymous responses: restricted stats return { "value": null, "restricted": true } instead of actual values. Free stats (population, area_sq_km, gdp_per_capita) include "restricted": false. Get a free API key for full access to all 25+ statistics.
Rate Limits
| Plan | Per minute | Per day | Price |
|---|---|---|---|
| Anonymous | 10 | 100 | Free (no key) |
| Free | 30 | 1,000 | $0 |
| Pro | 60 | 10,000 | $19.99/mo |
| Premium | 300 | 50,000 | $39.99/mo |
| Enterprise | 600 | 500,000 | Custom |
Rate limit headers are included in every response: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset.
Anonymous requests have a mandatory 5-second cooldown between requests. Get a free API key at /developers/quickstart for instant access with no cooldown.
Pagination
Paginated endpoints accept page and per_page query parameters. Default: page=1, per_page=25 (max 100).
{
"data": [...],
"pagination": {
"page": 1,
"per_page": 25,
"total": 261,
"total_pages": 11
},
"meta": {
"request_id": "req_abc123",
"timestamp": "2026-03-11T10:00:00.000Z",
"cached": true
}
}Error Handling
{
"error": {
"code": "NOT_FOUND",
"message": "Country \"xyz\" not found.",
"status": 404
},
"meta": {
"request_id": "req_abc123",
"timestamp": "2026-03-11T10:00:00.000Z"
}
}| Status | Code | Description |
|---|---|---|
| 400 | BAD_REQUEST | Invalid parameters |
| 401 | INVALID_API_KEY | Invalid or missing API key |
| 403 | API_KEY_DISABLED | API key has been disabled |
| 404 | NOT_FOUND | Resource not found |
| 429 | RATE_LIMIT_EXCEEDED | Too many requests |
| 500 | INTERNAL_ERROR | Server error |
Endpoint Reference
/api/v1/countriesPaginated list of all countries with basic stats.
| Name | Type | Required | Description |
|---|---|---|---|
page | integer | No | Page number (default: 1) |
per_page | integer | No | Items per page (default: 25, max: 100) |
region | string | No | Filter by region slug (e.g. south-america) |
sort | string | No | Sort by: name, population, area (default: name) |
curl -H "X-API-Key: bw_live_your_key" \
"https://bamwor.com/api/v1/countries?sort=population&per_page=5"{
"data": [
{
"iso_code": "CH",
"names": { "en": "China", "es": "China", "pt": "China", "it": "Cina" },
"slugs": { "en": "china", "es": "china", "pt": "china", "it": "cina" },
"coordinates": { "latitude": 35.0, "longitude": 105.0 },
"region": { "slug": "east-southeast-asia", "name": "East & Southeast Asia" },
"population": 1416043270,
"area_sq_km": 9596960,
"category": "country"
}, ...
],
"pagination": { "page": 1, "per_page": 5, "total": 261, "total_pages": 53 }
}/api/v1/countries/:slugFull country detail with all statistics.
| Name | Type | Required | Description |
|---|---|---|---|
slug | string | Yes | Country slug in any language (e.g. argentina, japon), ISO code (AR, JP, US), or alias (usa, uk, vatican-city, uae) |
curl -H "X-API-Key: bw_live_your_key" \
https://bamwor.com/api/v1/countries/japan{
"data": {
"gec_code": "JA",
"iso_code": "JA",
"names": { "en": "Japan", "es": "Japón", "pt": "Japão", "it": "Giappone" },
"population": 123719238,
"population_year": 2025,
"area_sq_km": 377915,
"stats": {
"population": { "value": 123719238, "unit": "people", "year": 2025, "source": "CIA World Factbook" },
"gdp_ppp": { "value": 6025000000000, "unit": "USD", "year": 2023, "source": "CIA World Factbook" },
"ibeu": { "value": 56.32, "unit": "index score", "year": 2026, "source": "Bamwor Proprietary Index" },
...
},
"flag_url": "/flags/ja.png",
"map_url": "/maps/ja.png"
}
}
// gec_code: FIPS 10-4 country code (2 chars, differs from ISO 3166-1)
// population_year: year of the population estimate
// stats include 9 Bamwor indices (ibeu, ibcp, ibda, ibcx, ibee, ibfm, ibdi, ibed, ibsa)/api/v1/countries/:slug/citiesPaginated cities within a country.
| Name | Type | Required | Description |
|---|---|---|---|
slug | string | Yes | Country slug |
sort | string | No | Sort by: population, name (default: population) |
min_population | integer | No | Minimum population filter |
province | string | No | Filter by province/admin1 name |
page | integer | No | Page number |
per_page | integer | No | Items per page (max: 100) |
curl -H "X-API-Key: bw_live_your_key" \
"https://bamwor.com/api/v1/countries/brazil/cities?min_population=500000"{
"data": [
{
"id": 3448439,
"names": { "en": "São Paulo", "es": "São Paulo", ... },
"coordinates": { "latitude": -23.5475, "longitude": -46.6361 },
"population": 11967825,
"province": "São Paulo"
}, ...
],
"pagination": { "page": 1, "per_page": 25, "total": 17 }
}/api/v1/cities/:idCity detail by GeoNames ID.
| Name | Type | Required | Description |
|---|---|---|---|
id | integer | Yes | GeoNames ID (e.g. 3435910 for Buenos Aires) |
curl -H "X-API-Key: bw_live_your_key" \
https://bamwor.com/api/v1/cities/3435910{
"data": {
"id": 3435910,
"names": { "en": "Buenos Aires", ... },
"coordinates": { "latitude": -34.6132, "longitude": -58.3772 },
"population": 13076300,
"elevation": 31,
"timezone": "America/Argentina/Buenos_Aires",
"province": "Buenos Aires F.D.",
"country": { "name": "Argentina", "slug": "argentina", "iso_code": "AR" }
}
}/api/v1/cities/:id/nearbyFind cities near a given city using PostGIS radius search.
| Name | Type | Required | Description |
|---|---|---|---|
id | integer | Yes | Origin city GeoNames ID |
radius | integer | No | Radius in km (default: 50, max: 200) |
limit | integer | No | Max results (default: 10, max: 50) |
curl -H "X-API-Key: bw_live_your_key" \
"https://bamwor.com/api/v1/cities/3435910/nearby?radius=100&limit=5"{
"data": [
{
"id": 3432043,
"names": { "en": "La Plata", ... },
"coordinates": { "latitude": -34.9215, "longitude": -57.9545 },
"population": 694167,
"distance_km": 56.2
}, ...
],
"pagination": { "page": 1, "per_page": 5, "total": 5, "total_pages": 1 }
}/api/v1/searchSearch countries and cities by name in any of the 4 supported languages.
| Name | Type | Required | Description |
|---|---|---|---|
q | string | Yes | Search query (min 2 chars, max 100) |
type | string | No | Filter: all, country, city (default: all) |
limit | integer | No | Max results (default: 20, max: 50) |
curl -H "X-API-Key: bw_live_your_key" \
"https://bamwor.com/api/v1/search?q=tokyo&type=city"{
"data": [
{
"type": "city",
"id": 1850147,
"names": { "en": "Tokyo", "es": "Tokio", "pt": "Tóquio", "it": "Tokyo" },
"coordinates": { "latitude": 35.6895, "longitude": 139.6917 },
"population": 8336599,
"country_code": "JA"
}
]
}/api/v1/rankingsList all available ranking metrics.
curl -H "X-API-Key: bw_live_your_key" \
https://bamwor.com/api/v1/rankings{
"data": [
{ "slug": "population", "label": "Population", "url": "/api/v1/rankings/population" },
{ "slug": "area", "label": "Area (sq km)", "url": "/api/v1/rankings/area" },
{ "slug": "gdp", "label": "GDP (nominal)", "url": "/api/v1/rankings/gdp" },
{ "slug": "hdi", "label": "Human Development Index", "url": "/api/v1/rankings/hdi" },
...
]
}/api/v1/rankings/:slugPaginated country ranking by a specific metric.
| Name | Type | Required | Description |
|---|---|---|---|
slug | string | Yes | Metric: population, area, density, gdp, gdp-per-capita, hdi, life-expectancy, ibeu, ibcp, ibda, ibcx, ibee, ibfm, ibdi, ibed, ibsa (16 total) |
region | string | No | Filter by region slug |
countries_only | boolean | No | When true, excludes non-country entities (World, EU, territories). Default: false |
page | integer | No | Page number |
per_page | integer | No | Items per page (default: 50) |
curl -H "X-API-Key: bw_live_your_key" \
"https://bamwor.com/api/v1/rankings/population?region=south-america&per_page=5"{
"data": [
{
"rank": 1,
"country": {
"iso_code": "BR",
"names": { "en": "Brazil", ... },
"region": { "slug": "south-america", "name": "South America" }
},
"value": 220051512,
"unit": null,
"year": 2025
}, ...
],
"pagination": { "page": 1, "per_page": 5, "total": 14 }
}Country Sections (Narrative Content)
Access detailed narrative content for any country — government structure, economy overview, demographics, military, infrastructure, and more. Data sourced from the CIA World Factbook. This country profile API endpoint serves the same structured content that powered the World Factbook — ideal for building country encyclopedias, educational apps, and AI agents.
Access: Premium and Enterprise plans. Demo countries (Colombia, Italy, Australia) available on all plans including anonymous.
/api/v1/countries/:slug/sectionsNarrative country profile with 13 sections: introduction, geography, people-and-society, government, economy, energy, communications, transportation, military-and-security, terrorism, transnational-issues, space, environment.
| Name | Type | Required | Description |
|---|---|---|---|
slug | string | Yes | Country slug, ISO code (AR, JP), or alias (usa, uk) |
section | string | No | Specific section key (e.g. government, economy). Omit for all sections. |
lang | string | No | Language: en, es, pt, it (default: en) |
curl -H "X-API-Key: bw_live_your_key" \
"https://bamwor.com/api/v1/countries/argentina/sections?section=government"{
"data": {
"country": { "name": "Argentina", "slug": "argentina", "iso_code": "AR" },
"sections": {
"government": {
"Country name": { "conventional long form": { "text": "Argentine Republic" }, ... },
"Government type": { "text": "presidential republic" },
"Capital": { "name": { "text": "Buenos Aires" }, ... },
...
}
},
"section_count": 1
}
}
// Non-premium: 403 PREMIUM_REQUIRED (demo: colombia, italy, australia)API Key Management
/api/v1/keysRegister a new free API key.
| Name | Type | Required | Description |
|---|---|---|---|
email | string | Yes | Your email address |
name | string | No | App or project name |
curl -X POST https://bamwor.com/api/v1/keys \
-H "Content-Type: application/json" \
-d '{"email": "[email protected]", "name": "My App"}'{
"data": {
"api_key": "bw_live_a1b2c3d4e5f6...",
"plan": "free",
"limits": { "per_minute": 30, "per_day": 1000 },
"message": "Store this key securely — it cannot be retrieved later."
}
}/api/v1/keys/usageCheck your current API key usage and remaining limits.
curl -H "X-API-Key: bw_live_your_key" \
https://bamwor.com/api/v1/keys/usage{
"data": {
"plan": "free",
"usage": {
"minute": { "used": 5, "limit": 30, "resets_in": 42 },
"day": { "used": 127, "limit": 1000, "resets_in": 54321 }
}
}
}