Skip to content

API Documentation

The Sports Live application provides a RESTful API’s for accessing live sports data, user preferences, and reporting functionality. The API is designed to be internal and external friendly, supports real-time updates, and follows established API design principles.


  • All endpoints are used by the frontend for live updates, user preferences, admin operations, and reporting.
  • Full read/write access is supported with appropriate authentication.
  • External users (e.g., third-party apps) can access read-only endpoints:
    • /api/matches
    • /api/players
    • /api/teams
    • /api/standings
  • External POST/PUT/DELETE requests require authentication

  • RESTful Design: Each resource has its own endpoint.
  • HTTP Methods:
    • GET → Fetch data
    • POST → Create new resources
    • PUT → Update existing resources
    • DELETE → Remove resources
  • Hierarchical organization:
    • /api/matches/:id/events → Nested events for a match
    • /api/users/:id/favorites → User-specific favorite teams

API Architecture Diagram


EndpointMethodDescription
/api/matchesGETFetch all live and upcoming matches
/api/matches/:idGETFetch a single match by ID
/api/matchesPOSTCreate new match(es)
/api/matches/:idPUTUpdate match information
/api/matches/:idDELETEDelete a match

Example Response (GET /api/matches):

Terminal window
{
"data": [
{
"id": "123",
"home_team": "Team A",
"away_team": "Team B",
"score": "2-1",
"status": "live",
"start_time": "2025-09-19T14:00:00Z"
}
]
}
EndpointMethodDescription
/api/playersGETFetch all players
/api/players/:idGETFetch a specific player by ID

Example Response (GET /api/players):

Terminal window
{
"data": [
{ "id": "1", "name": "John Doe", "team": "Team A", "position": "Forward" }
]
}
EndpointMethodDescription
/api/teamsGETFetch all teams
/api/teams/:idGETFetch a specific team by ID
/api/teamsPOSTCreate new teams (admin only)

Example Response (GET /api/teams):

Terminal window
{
"data": [
{ "id": "101", "name": "Team A", "logo_url": "https://example.com/logoA.png" },
{ "id": "102", "name": "Team B", "logo_url": "https://example.com/logoB.png" }
]
}

EndpointMethodDescription
/api/standingsGETFetch competition standings
/api/standings/:idGETFetch standings for a specific competition/season

Example Response (GET /api/standings):

Terminal window
{
"data": [
{ "rank": 1, "team": "Team A", "points": 45 },
{ "rank": 2, "team": "Team B", "points": 42 }
]
}

  • Stores and manages user favorite teams.
  • Requires user authentication.
  • User Favorites API: /api/users/:id/favorites
EndpointMethodDescription
/api/users/:id/favoritesGETGet user favorite teams
/api/users/:id/favoritesPOSTAdd a team to favorites
/api/users/:id/favorites/:teamNameDELETERemove a team from favorites
/api/users/:id/favoritesPUTUpdate all favorites

Example Response (GET /api/users/:id/favorites):

Terminal window
{
"data": ["Team A", "Team C"]
}

EndpointMethodDescription
/api/reportingGETFetch all reports
/api/reporting/:idGETFetch a specific report
/api/reportingPOSTCreate a report
/api/reporting/:idPUTUpdate a report
/api/reporting/:idDELETEDelete a report

Example Response (POST /api/reporting):

Terminal window
{
"data": { "id": "901", "title": "Injury Report", "description": "Player injured during match." }
}

  • Hosting: API is deployed on Render.com with a MongoDB backend.
  • CI/CD: Continuous integration ensures backend code is deployed after successful builds.
  • Integration: Connected with frontend via REST calls and WebSocket polling for real-time updates.

API Deployment


  • Load Handling: Supports up to 500 simultaneous match/event updates per minute.
  • Error Handling: Returns HTTP error codes with descriptive error messages.
  • Monitoring Tools: Render logs, backend middleware, and automated error reporting.

API Monitoring


  • HTTP Methods Correctness: GET, POST, PUT, DELETE follow REST standards.
  • No Redundant Endpoints: Single source of truth per resource.
  • Hierarchical Organization: Matches, events, and users modeled as nested resources.
  • Response Consistency: All endpoints return JSON with the same schema.
  • Authentication & Authorization: Required for modifying resources.

  • Realtime DB Listener: onValue(ref(db, 'matches'), callback) for live updates.
  • Supports: matches, teams, and user favorites.
  • Polling Interval: 30 seconds (configurable).

Real-Time Updates


Terminal window
import { apiClient } from './api';
async function loadLiveMatches() {
const matches = await apiClient.getMatches();
console.log(matches.data);
}
loadLiveMatches();