Welcome to the Foosball API, a powerful backend built with NestJS to manage foosball games, track statistics, and enhance community engagement. Whether you're running casual matches or organizing competitive tournaments, this API provides the tools you need with a modular and scalable design.
The Game Component is the core of the Foosball API, designed to manage and analyze foosball matches comprehensively.
-
Real-Time Statistics Tracking:
Track game statistics as they happen using NestJS's WebSocket support. Connect to our WebSocket endpoint to get live updates on scores, player actions, and game events. This feature is perfect for real-time dashboards or live match updates. -
Retrieve Statistics by Games:
Access detailed statistics for any game, past or present, via RESTful endpoints. For example:GET /games/:id/stats
Retrieve data like final scores, player contributions, and match duration to analyze performance or generate reports.
Stay informed with our event-driven Notification Listeners, built using NestJS's event emitter module.
-
Listening for Game Start Events:
The system listens for events like the start of a game and instantly notifies subscribed clients or services, ensuring you never miss a kickoff. -
MVP Polls:
After a game ends, an MVP poll is launched. Players and spectators can vote for the Most Valuable Player through the API, with results aggregated in real-time for an interactive experience.
The Telegram Integration feature connects your foosball community directly to Telegram for seamless communication.
-
Sending Messages:
Automatically send messages to your Telegram group for key events, such as:- "Game has started between Player A and Player B!"
- "New tournament generated—check the schedule!"
Configure your Telegram bot token in the
.envfile to enable this feature.
-
Tournament Schedule Screenshots:
Generate and send screenshots of tournament schedules to your Telegram group. These visuals help participants plan and discuss upcoming matches easily.
The Organizations feature lets you manage foosball activities within specific groups.
- Track Statistics Inside Your Organization:
Create an organization (e.g., for your company or club) to track isolated statistics. Monitor leaderboards, win rates, and player performance specific to your group, making it ideal for internal leagues or friendly competitions.
Organize your foosball data with the Seasons feature.
- Seasonal Management:
Define seasons to segment games, tournaments, and statistics over time. This allows you to:- Reset stats for a fresh start each season
- Compare performance across seasons
- Archive past seasons for historical reference
Seasons keep your data structured and meaningful.
Get detailed insights into player performance with the Player Statistics feature.
- Available Statistics:
Access a wide range of metrics for each player, such as:- Win/loss record
- Goals scored and conceded
- Win rate percentage
- Performance trends over time
- Head-to-head stats against opponents
Retrieve this data via:
Use these stats to build leaderboards, analyze skills, or integrate with other tools.GET /players/:id/stats
- Node.js (v14 or higher)
- MongoDB (local or cloud-hosted)
- Git
-
Clone the Repository:
git clone https://github.com/vkorop/foosball-api.git
-
Switch to the Dev Branch:
cd foosball-api git checkout dev -
Install Dependencies:
npm install
-
Configure Environment Variables:
- Copy the example
.envfile:cp .env.example .env
- Update
.envwith your MongoDB connection string, Telegram bot token, and other settings (e.g.,PORT).
- Copy the example
-
Launch the Server:
npm run start:dev
The API will be available at
http://localhost:3000(or your configured port).
-
Create a Game
POST /games
Request:{ "player1": "playerID1", "player2": "playerID2" }Response:
{ "id": "gameID", "player1": "playerID1", "player2": "playerID2", "score": { "player1": 0, "player2": 0 }, "status": "ongoing" } -
Get Game Statistics
GET /games/:id/stats
- Get Player Statistics
GET /players/:id/stats
Response:{ "id": "playerID", "name": "John Doe", "wins": 10, "losses": 5, "goalsScored": 25, "winRate": 66.67 }
We welcome contributions! To get started:
- Fork the repository.
- Create a branch (
git checkout -b feature/your-idea). - Commit your changes (
git commit -m "Add your idea"). - Push to your branch (
git push origin feature/your-idea). - Submit a pull request.
This project is licensed under the MIT License. See LICENSE for details.
Have questions? Open an issue or reach out at your-email@example.com.
"Spin, score, and stats—Foosball API brings the game to life!"