← Back to Docs

API Reference

Complete endpoint documentation for the CPL Analytics API

Overview

The CPL Analytics API provides read-only access to Canadian Premier League match data, standings, and team information. All endpoints return JSON responses.

Base URL

https://canadasoccerapi.com

For local development: http://localhost:3000

Authentication

No authentication required

The API is publicly accessible for educational and research purposes.

Rate Limits

Tier Limit Window
Public (testing) 20 requests per hour per IP

When rate limited, the API returns HTTP 429 with a Retry-After header.

GET

/api/matches

Retrieve historical match data with optional filtering and pagination.

Parameters

Parameter Type Required Description
season Integer No Filter by season year (2019-2025)
team String No Filter by team name (case-insensitive, partial match)
limit Integer No Maximum results per page (default: 100, max: 500)
offset Integer No Number of results to skip (default: 0)

Example Requests

# Get all matches

curl "https://canadasoccerapi.com/api/matches"

# Get 2024 season matches

curl "https://canadasoccerapi.com/api/matches?season=2024"

# Get Forge FC matches with pagination

curl "https://canadasoccerapi.com/api/matches?team=Forge&limit=10&offset=0"

Example Response

{
  "total": 156,
  "count": 2,
  "offset": 0,
  "limit": 2,
  "matches": [
    {
      "date": "2024-04-13",
      "home_team": "Forge FC",
      "away_team": "Atletico Ottawa",
      "home_goals": 3,
      "away_goals": 1,
      "season": 2024,
      "venue": "Tim Hortons Field"
    },
    {
      "date": "2024-04-14",
      "home_team": "Cavalry FC",
      "away_team": "Pacific FC",
      "home_goals": 2,
      "away_goals": 2,
      "season": 2024,
      "venue": "ATCO Field"
    }
  ]
}
GET

/api/standings

Get league standings for one or all seasons.

Parameters

Parameter Type Required Description
season Integer No Specific season year (omit for all seasons)

Example Request

curl "https://canadasoccerapi.com/api/standings?season=2024"

Example Response

{
  "season": 2024,
  "standings": [
    {
      "position": 1,
      "team": "Forge FC",
      "played": 28,
      "wins": 18,
      "draws": 5,
      "losses": 5,
      "goals_for": 52,
      "goals_against": 28,
      "goal_difference": 24,
      "points": 59
    }
  ],
  "source": "official"
}

Data Source Field

"official" From official CanPL SDP API (excludes playoffs)
"calculated" Calculated from match results
GET

/api/teams

Get information about CPL teams including metadata.

Parameters

Parameter Type Required Description
active_only String No Set to "true" to exclude inactive teams

Example Request

curl "https://canadasoccerapi.com/api/teams?active_only=true"

Example Response

{
  "count": 8,
  "teams": [
    {
      "name": "Forge FC",
      "city": "Hamilton",
      "stadium": "Tim Hortons Field",
      "founded": 2018,
      "latitude": 43.2557,
      "longitude": -79.8711,
      "surface": "grass",
      "status": "active"
    }
  ]
}

Error Handling

HTTP Status Codes

Code Meaning Description
200 OK Request successful
400 Bad Request Invalid parameters
404 Not Found Endpoint does not exist
429 Too Many Requests Rate limit exceeded
500 Server Error Internal server error

Error Response Format

{
  "error": "Failed to load matches data"
}

CORS Support

The API supports Cross-Origin Resource Sharing (CORS) for browser-based applications.

CORS Headers

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, OPTIONS
Access-Control-Allow-Headers: Content-Type

Browser Usage

// Works directly in browser without proxy
fetch('https://canadasoccerapi.com/api/matches')
  .then(response => response.json())
  .then(data => console.log(data.matches));

Caching

Endpoint Cache Duration
/api/matches 1 hour
/api/standings 1 hour
/api/teams 24 hours

Related Documentation