Documentazione API REST

Riferimento completo API per endpoint di paesi, città, classifiche e ricerca. Esempi di codice in JavaScript e Python. Autenticazione, limiti. Piano gratuito.

Base URL

https://bamwor.com/api/v1

Autenticazione

Includi la tua API key in ogni richiesta usando uno di questi metodi:

Header
X-API-Key: bw_live_your_key_here
# or
Authorization: Bearer bw_live_your_key_here

Le richieste anonime (senza key) sono consentite con limiti inferiori: 10/min, 100/giorno.

Risposte anonime: le statistiche ristrette restituiscono { "value": null, "restricted": true } invece dei valori reali. Statistiche gratuite (population, area_sq_km, gdp_per_capita) includono "restricted": false. Ottieni una API key gratuita per accesso completo a oltre 25 statistiche.

Limiti di Utilizzo

PlanAl minutoAl giornoPrezzo
Anonymous10100Gratuito (senza key)
Free301,000$0
Pro6010,000$19.99/mo
Premium30050,000$39.99/mo
Enterprise600500,000Personalizzato

Gli header di rate limit sono inclusi in ogni risposta: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset.

Le richieste anonime hanno un'attesa obbligatoria di 5 secondi tra le richieste. Ottieni una API key gratuita su /developers/quickstart per accesso istantaneo senza attesa.

Paginazione

Gli endpoint paginati accettano i parametri page e per_page. Default: page=1, per_page=25 (max 100).

Response format
{
  "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
  }
}

Gestione Errori

Error response
{
  "error": {
    "code": "NOT_FOUND",
    "message": "Country \"xyz\" not found.",
    "status": 404
  },
  "meta": {
    "request_id": "req_abc123",
    "timestamp": "2026-03-11T10:00:00.000Z"
  }
}
StatusCodeDescrizione
400BAD_REQUESTParametri non validi
401INVALID_API_KEYAPI key non valida o mancante
403API_KEY_DISABLEDAPI key disabilitata
404NOT_FOUNDRisorsa non trovata
429RATE_LIMIT_EXCEEDEDTroppe richieste
500INTERNAL_ERRORErrore del server

Riferimento Endpoint

GET/api/v1/countries

Lista paginata di tutti i paesi con statistiche di base.

NameTypeRequiredDescription
pageintegerNoPage number (default: 1)
per_pageintegerNoItems per page (default: 25, max: 100)
regionstringNoFilter by region slug (e.g. south-america)
sortstringNoSort by: name, population, area (default: name)
curl
curl -H "X-API-Key: bw_live_your_key" \
  "https://bamwor.com/api/v1/countries?sort=population&per_page=5"
Response
{
  "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 }
}
GET/api/v1/countries/:slug

Dettaglio completo del paese con tutte le statistiche.

NameTypeRequiredDescription
slugstringYesCountry slug in any language (e.g. argentina, japon), ISO code (AR, JP, US), or alias (usa, uk, vatican-city, uae)
curl
curl -H "X-API-Key: bw_live_your_key" \
  https://bamwor.com/api/v1/countries/japan
Response
{
  "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)
GET/api/v1/countries/:slug/cities

Città paginate all'interno di un paese.

NameTypeRequiredDescription
slugstringYesCountry slug
sortstringNoSort by: population, name (default: population)
min_populationintegerNoMinimum population filter
provincestringNoFilter by province/admin1 name
pageintegerNoPage number
per_pageintegerNoItems per page (max: 100)
curl
curl -H "X-API-Key: bw_live_your_key" \
  "https://bamwor.com/api/v1/countries/brazil/cities?min_population=500000"
Response
{
  "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 }
}
GET/api/v1/cities/:id

Dettaglio della città per ID GeoNames.

NameTypeRequiredDescription
idintegerYesGeoNames ID (e.g. 3435910 for Buenos Aires)
curl
curl -H "X-API-Key: bw_live_your_key" \
  https://bamwor.com/api/v1/cities/3435910
Response
{
  "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" }
  }
}
GET/api/v1/cities/:id/nearby

Trovare città vicine usando ricerca per raggio PostGIS.

NameTypeRequiredDescription
idintegerYesOrigin city GeoNames ID
radiusintegerNoRadius in km (default: 50, max: 200)
limitintegerNoMax results (default: 10, max: 50)
curl
curl -H "X-API-Key: bw_live_your_key" \
  "https://bamwor.com/api/v1/cities/3435910/nearby?radius=100&limit=5"
Response
{
  "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 }
}
GET/api/v1/search

Cerca paesi e città per nome in una delle 4 lingue supportate.

NameTypeRequiredDescription
qstringYesSearch query (min 2 chars, max 100)
typestringNoFilter: all, country, city (default: all)
limitintegerNoMax results (default: 20, max: 50)
curl
curl -H "X-API-Key: bw_live_your_key" \
  "https://bamwor.com/api/v1/search?q=tokyo&type=city"
Response
{
  "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"
    }
  ]
}
GET/api/v1/rankings

Elenco di tutte le metriche di classifica disponibili.

curl
curl -H "X-API-Key: bw_live_your_key" \
  https://bamwor.com/api/v1/rankings
Response
{
  "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" },
    ...
  ]
}
GET/api/v1/rankings/:slug

Classifica paginata dei paesi per una metrica specifica.

NameTypeRequiredDescription
slugstringYesMetric: population, area, density, gdp, gdp-per-capita, hdi, life-expectancy, ibeu, ibcp, ibda, ibcx, ibee, ibfm, ibdi, ibed, ibsa (16 total)
regionstringNoFilter by region slug
countries_onlybooleanNoWhen true, excludes non-country entities (World, EU, territories). Default: false
pageintegerNoPage number
per_pageintegerNoItems per page (default: 50)
curl
curl -H "X-API-Key: bw_live_your_key" \
  "https://bamwor.com/api/v1/rankings/population?region=south-america&per_page=5"
Response
{
  "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 }
}

Sezioni dei Paesi (Contenuto Narrativo)

Accedi a contenuto narrativo dettagliato per qualsiasi paese — struttura governativa, economia, demografia, forze armate, infrastrutture e altro. Dati dal CIA World Factbook. Questo endpoint serve lo stesso contenuto che alimentava il World Factbook — ideale per enciclopedie, app educative e agenti IA.

Accesso: piani Premium ed Enterprise. Paesi demo (Colombia, Italia, Australia) disponibili su tutti i piani incluso anonimo.

GET/api/v1/countries/:slug/sections

Profilo narrativo del paese con 13 sezioni: introduzione, geografia, società, governo, economia, energia, comunicazioni, trasporti, forze armate, terrorismo, questioni transnazionali, spazio, ambiente.

NameTypeRequiredDescription
slugstringYesCountry slug, ISO code (AR, JP), or alias (usa, uk)
sectionstringNoSpecific section key (e.g. government, economy). Omit for all sections.
langstringNoLanguage: en, es, pt, it (default: en)
curl
curl -H "X-API-Key: bw_live_your_key" \
  "https://bamwor.com/api/v1/countries/argentina/sections?section=government"
Response
{
  "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)

Gestione API Key

POST/api/v1/keys

Registrare una nuova API key gratuita.

NameTypeRequiredDescription
emailstringYesYour email address
namestringNoApp or project name
curl
curl -X POST https://bamwor.com/api/v1/keys \
  -H "Content-Type: application/json" \
  -d '{"email": "[email protected]", "name": "My App"}'
Response
{
  "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."
  }
}
GET/api/v1/keys/usage

Verifica l'uso attuale della tua API key e i limiti rimanenti.

curl
curl -H "X-API-Key: bw_live_your_key" \
  https://bamwor.com/api/v1/keys/usage
Response
{
  "data": {
    "plan": "free",
    "usage": {
      "minute": { "used": 5, "limit": 30, "resets_in": 42 },
      "day": { "used": 127, "limit": 1000, "resets_in": 54321 }
    }
  }
}