This is the backend API for the 0 C.E. game, providing essential services and data to support game functionality. The API is currently in development and will expand with more endpoints and features over time.
The 0 C.E. API is built with Flask and uses JSON for data communication. Initially, it provides a basic endpoint for retrieving the server time, but it will expand as more game functionality is implemented.
To run the API locally, you’ll need:
- Docker to build and run the application in a container.
- Build the Docker Image:
docker build -t 0ce-flask-api .
- Run the Docker Container:
docker run -d -p 5000:5000 --name 0CE_API 0ce-flask-api
- Access the API:
Open your browser or API client to
http://localhost:5000
.
-
Description: This endpoint returns the current server time.
-
Method:
GET
-
URL:
/time
-
Response:
{ "status": "success", "data": { "server_time": "2023-12-01T12:34:56Z" } }
Sample Response (Error):
{ "status": "error", "message": "Resource not found" }
Note: Additional endpoints will be added as the game develops.
To maintain consistency across responses, all data responses will follow a standard JSON format:
- Success:
{ "status": "success", "data": { ... } }
- Error:
{ "status": "error", "message": "Error message here" }
This structure allows easy parsing of successful responses and clear indication of errors.
The API is designed to run within a Docker container. Here’s a breakdown of the Dockerfile configuration and commands for running the container.
The Dockerfile uses the official python:3.13-slim
image and installs dependencies from requirements.txt
. A health check verifies the container’s status every 30 seconds.
To run the container, expose it on port 5000:
docker run -p 5000:5000 0ce-flask-api
Access the API via http://localhost:5000
.
Planned API enhancements:
- User Authentication: Implementing a secure user authentication system.
- Additional Endpoints: To support game features like city management, alliances, resources, and combat.
- Error Handling and Logging: Structured error codes and enhanced logging for debugging and monitoring.
- API Versioning: To support backward compatibility in future versions.