Base URL: http://localhost:8000
All responses use the standard envelope:
{
"ok": true,
"data": { ... },
"error": null
}On error:
{
"ok": false,
"data": null,
"error": {
"code": "validation_error",
"message": "…",
"details": null
}
}Every authenticated endpoint requires one of:
Authorization: Bearer <access_token>header, orX-Api-Token: <access_token>header.
Tokens are obtained via /auth/register or /auth/login.
// Request
{
"telegram_id": 123456789,
"username": "alice",
"locale": "en",
"password": "supersecret"
}
// Response (200)
{
"ok": true,
"data": {
"access_token": "eyJhbGciOi...",
"refresh_token": "eyJhbGciOi...",
"token_type": "Bearer",
"expires_in": 900,
"player": {
"id": 1,
"telegram_id": 123456789,
"username": "alice",
"locale": "en",
"role": "player",
"is_banned": false,
"world_id": null,
"country_id": null
}
}
}Same body as register (minus username and locale).
{ "refresh_token": "…" }{ "refresh_token": "…" }List open worlds.
Get a world by id.
Countries in the world that have no player yet.
All countries in a world.
{ "world_id": 1, "country_code": "IR" }Abandon your current country.
Full snapshot of your country (country, resources, buildings, units).
Single country.
Your buildings.
{ "building_key": "farm", "count": 1 }{ "building_id": 42 }{ "tech_key": "mechanical_engineering" }Your units.
{ "unit_key": "infantry", "count": 10 }{ "defender_id": 5, "war_type": "conventional" }{
"war_id": 1,
"attacker_units": { "infantry": 100, "tank": 10 },
"defender_units": { "infantry": 50 }
}Your active wars.
Your market orders.
{
"side": "buy",
"resource_key": "oil",
"quantity": 100,
"unit_price": 25,
"expires_in_seconds": 86400
}Cancel an open order; refunds the unfilled portion.
POST /social/alliance/create—{ "name": "Allies", "tag": "ALY" }POST /social/alliance/invite—{ "country_id": 5 }POST /social/alliance/join/{alliance_id}POST /social/alliance/leave
POST /social/diplomacy—{ "other_country_id": 5, "status": "allied" }GET /social/diplomacy
GET /social/missionsPOST /social/mission/claim—{ "mission_id": 7 }
GET /social/notifications?limit=20POST /social/notifications/{id}/read
GET /social/rankings/{world_id}?metric=population&limit=50
Available metrics: population, treasury, approval, stability,
education, healthcare, military_power, gdp, research_points.
Admin endpoints require role ∈ {admin, owner} in the JWT.
POST /admin/broadcast—{ "message": "…", "locale": "en" }POST /admin/ban/{target_id}POST /admin/unban/{target_id}GET /admin/pluginsPOST /admin/plugins/{plugin_id}/disablePOST /admin/game-data/reloadGET /admin/metrics
{ "ok": true, "status": "ok", "version": "1.0.0" }| Code | HTTP | Meaning |
|---|---|---|
validation_error |
422 | Request body failed schema validation |
not_found |
404 | Resource not found |
conflict |
409 | State conflict (e.g. country already taken) |
authentication_failed |
401 | Missing or invalid token |
forbidden |
403 | Insufficient permissions |
rate_limited |
429 | Rate limit exceeded |
game_rule_violation |
400 | Action violates game rules |
insufficient_resources |
400 | Not enough resources to perform action |
plugin_error |
500 | Plugin raised an exception |
internal_error |
500 | Unhandled server error |