http://localhost:5000/api
GET /api/healthCheck API health and collector status.
Response:
{
"status": "healthy",
"collector_running": true
}GET /Get API information and documentation links.
Response:
{
"name": "Hell Divers 2 API",
"version": "1.0.0",
"description": "Real-time scraper for Hell Divers 2 game data",
"docs": "/docs",
"redoc": "/redoc"
}GET /api/war/statusGet the current war status.
Response:
{
"id": 1,
"status": "active",
"message": "The war is ongoing"
}POST /api/war/status/refreshManually trigger a refresh of war status data.
Response:
{
"success": true,
"data": { /* war status data */ }
}GET /api/campaignsGet campaign information from the Hell Divers 2 API.
Cache Fallback: If upstream API is unavailable, returns most recent cached campaign data.
Response:
{
"campaigns": [
{
"id": 1,
"planet_index": 0,
"status": "active"
}
]
}Error Responses:
503 Service Unavailable: Upstream API failed and no cached data available
{
"detail": "No campaign data available (live fetch failed and no cached data)"
}GET /api/campaigns/activeGet only active campaigns from the database.
Response:
[
{
"id": 1,
"planet_index": 0,
"status": "active"
}
]GET /api/planetsGet information about all planets.
Cache Fallback: If upstream API is unavailable, returns most recent cached planet snapshot.
Response:
[
{
"index": 0,
"name": "Malevelon Creek",
"owner": "Humans",
"status": "contested"
}
]Error Responses:
503 Service Unavailable: Upstream API failed and no cached data available
{
"detail": "Failed to fetch planets and no cached data available"
}GET /api/planets/{planet_index}Get status of a specific planet.
Cache Fallback: If upstream API is unavailable, returns most recent cached status for this planet.
Parameters:
planet_index(integer): The planet index
Response:
{
"index": 0,
"name": "Malevelon Creek",
"owner": "Humans",
"status": "contested",
"biome": "Swamp"
}Error Responses:
503 Service Unavailable: Upstream API failed and no cached data for this planet
{
"detail": "Failed to fetch planet {planet_index} and no cached data available"
}GET /api/planets/{planet_index}/history?limit=10Get historical status data for a planet.
Parameters:
planet_index(integer): The planet indexlimit(integer, optional): Number of records (1-100, default: 10)
Response:
[
{
"data": { /* planet data */ },
"timestamp": "2024-01-15T10:30:00"
}
]GET /api/statisticsGet the latest global game statistics.
Response:
{
"total_players": 500000,
"total_kills": 1000000,
"missions_won": 50000,
"timestamp": "2024-01-15T10:30:00"
}GET /api/statistics/history?limit=100Get historical statistics data.
Parameters:
limit(integer, optional): Number of records (1-1000, default: 100)
Response:
[
{
"data": { /* statistics data */ },
"timestamp": "2024-01-15T10:30:00"
}
]POST /api/statistics/refreshManually trigger a refresh of statistics data.
Response:
{
"success": true,
"data": { /* statistics data */ }
}GET /api/factionsGet all faction information.
Cache Fallback: If upstream API is unavailable, returns factions from most recent cached war status.
Response:
[
{
"id": 1,
"name": "Humans",
"description": "The main player faction"
},
{
"id": 2,
"name": "Bugs",
"description": "Terminid enemies"
}
]Error Responses:
503 Service Unavailable: Upstream API failed and no cached faction data
{
"detail": "Failed to fetch factions and no cached data available"
}GET /api/biomesGet information about all available biomes.
Cache Fallback: If upstream API is unavailable, returns biomes from most recent cached planet data.
Response:
[
{
"id": 0,
"name": "Swamp",
"description": "Wet and muddy terrain"
},
{
"id": 1,
"name": "Desert",
"description": "Arid and sandy environment"
}
]Error Responses:
503 Service Unavailable: Upstream API failed and no cached biome data
{
"detail": "Failed to fetch biomes and no cached data available"
}GET /openapi.jsonGet the OpenAPI (formerly Swagger) schema.
http://localhost:5000/docs
Interactive API documentation with "Try it out" functionality.
http://localhost:5000/redoc
Alternative API documentation interface.
Returned when a resource doesn't exist or no data has been collected yet.
Example scenarios:
- Requesting history for a planet that has never been tracked
- Accessing active campaigns when none are currently active
- Querying data before the first collection cycle completes
{
"detail": "No war status data available"
}Returned when an unexpected server error occurs.
Example scenarios:
- Failed to refresh data due to scraper error
- Database write failure
- Unexpected exception in request handler
{
"detail": "Failed to fetch war status"
}New in cache-fallback feature: Returned by cache-enabled endpoints when BOTH conditions are true:
- Upstream Hell Divers 2 API is unavailable or returns an error
- No cached data exists in the database
Endpoints that return 503:
GET /api/campaignsGET /api/planetsGET /api/planets/{planet_index}GET /api/factionsGET /api/biomes
What this means for API consumers:
- A 503 response indicates a genuine service degradation (upstream down + no cache)
- A 200 response on these endpoints may contain cached data from the last successful collection
- Consider implementing retry logic with exponential backoff for 503 responses
- Monitor for persistent 503s which may indicate prolonged upstream outage
{
"detail": "No campaign data available (live fetch failed and no cached data)"
}Cache-enabled endpoints follow this logic:
- Try live API - Attempt to fetch fresh data from upstream
- Fallback to cache - If live fetch fails, try to retrieve from database
- Return 200 - If either live or cached data is available
- Return 503 - Only if both live fetch AND cache retrieval fail
This ensures maximum availability and resilience against upstream API outages.
{
"detail": [
{
"loc": ["query", "limit"],
"msg": "ensure this value is less than or equal to 1000",
"type": "value_error.number.not_le"
}
]
}Currently no rate limiting is implemented. Future versions may include:
- Request throttling per IP
- Daily request limits
- Concurrent connection limits
CORS is enabled for all origins. Requests from any origin are allowed:
- Origins:
* - Methods:
* - Headers:
*
Background data collection runs every 5 minutes by default.
This can be configured via environment variables or the src/config.py file.
Currently no authentication is required. Future versions may include:
- API key authentication
- JWT token support
- Rate limiting per key