GnistAI GnistAI
Log in

Getting Started with TheSportsDB (Sports Data)

Sports data — leagues, teams, players, events, and standings from TheSportsDB.

All Tutorials   |   Overview   |   Playground   |   MCP   |   REST API   |   Home
Entertainment

Data source: TheSportsDB (thesportsdb.com)

Overview

TheSportsDB (Sports Data) wraps TheSportsDB (thesportsdb.com), handling authentication, pagination, and rate limits for you. This tutorial covers all 8 tools with working code examples you can copy and run.

Prerequisites

  1. Sign up at https://context.gnist.ai/signup for a free API key (100 calls/day).
  2. Choose your integration method: MCP protocol or REST API.

Connect via MCP

Add to your MCP client config (Claude Desktop, Cursor, etc.):

MCP Config
{
  "mcpServers": {
    "gnist-thesportsdb": {
      "url": "https://context.gnist.ai/mcp/thesportsdb/",
      "headers": {
        "Gnist-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Tools (8)

search_teams

Search for sports teams by name across all sports. Returns matching teams with basic info including sport, league, country, and stadium. Use the returned team ID with get_team, get_last_events, or get_next_events. Examples: search_teams("Arsenal") -> Arsenal FC, Arsenal de Sarandi, etc. search_teams("Real Madrid") -> Real Madrid CF

ParameterTypeRequiredDescription
team_namestringrequiredTeam name to search for (e.g. 'Arsenal', 'Barcelona', 'Lakers').
curl -X POST "https://context.gnist.ai/mcp/thesportsdb/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "search_teams", "arguments": {"team_name": "'Arsenal'"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/thesportsdb/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'team_name': "'Arsenal'"}, 'name': 'search_teams'}},
)
print(resp.json())

get_team

Get detailed information for a specific team by its ID. Returns full team profile including stadium details, description, badge URL, jersey image, website, and league information. Use search_teams first to find the team ID.

ParameterTypeRequiredDescription
team_idstringrequiredNumeric team ID from TheSportsDB (e.g. '133604' for Arsenal).
curl -X POST "https://context.gnist.ai/mcp/thesportsdb/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "get_team", "arguments": {"team_id": "'133604'"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/thesportsdb/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'team_id': "'133604'"}, 'name': 'get_team'}},
)
print(resp.json())

search_players

Search for players by team name and/or player name. At least one of team_name or player_name must be provided. Returns player profiles including nationality, position, height, weight, and biography. Examples: search_players(player_name="Messi") -> Lionel Messi search_players(team_name="Arsenal", player_name="Saka") -> Bukayo Saka

ParameterTypeRequiredDescription
team_nameanyoptionalTeam name to filter players by (e.g. 'Arsenal').
player_nameanyoptionalPlayer name to search for (e.g. 'Messi', 'LeBron').
curl -X POST "https://context.gnist.ai/mcp/thesportsdb/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "search_players", "arguments": {"team_name": "'Arsenal'"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/thesportsdb/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'team_name': "'Arsenal'"}, 'name': 'search_players'}},
)
print(resp.json())

get_league_table

Get league standings/table for a given league and season. Returns the complete standings with points, wins, draws, losses, goals for/against, and goal difference for each team. Common league IDs: 4328 (EPL), 4335 (La Liga), 4331 (Bundesliga), 4332 (Serie A), 4334 (Ligue 1).

ParameterTypeRequiredDescription
league_idstringrequiredNumeric league ID (e.g. '4328' for English Premier League).
seasonstringrequiredSeason in YYYY or YYYY-YYYY format (e.g. '2024-2025').
curl -X POST "https://context.gnist.ai/mcp/thesportsdb/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "get_league_table", "arguments": {"league_id": "'4328'", "season": "'2024-2025'"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/thesportsdb/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'league_id': "'4328'", 'season': "'2024-2025'"},
            'name': 'get_league_table'}},
)
print(resp.json())

get_events_by_date

Get sporting events scheduled for a specific date. Returns events with home/away teams, scores (if completed), venue, and status. Optionally filter by sport. Examples: get_events_by_date("2025-03-15") -> all sports events on that date get_events_by_date("2025-03-15", sport="Soccer") -> only soccer matches

ParameterTypeRequiredDescription
datestringrequiredDate in YYYY-MM-DD format (e.g. '2025-03-15').
sportanyoptionalSport filter (e.g. 'Soccer', 'Basketball', 'Ice Hockey'). Omit for all sports.
curl -X POST "https://context.gnist.ai/mcp/thesportsdb/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "get_events_by_date", "arguments": {"date": "'2025-03-15'"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/thesportsdb/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'date': "'2025-03-15'"},
            'name': 'get_events_by_date'}},
)
print(resp.json())

get_last_events

Get the last 5 completed events for a team. Returns recent match results including scores, opponents, venue, and date. Useful for checking recent form.

ParameterTypeRequiredDescription
team_idstringrequiredNumeric team ID (e.g. '133604' for Arsenal). Use search_teams to find it.
curl -X POST "https://context.gnist.ai/mcp/thesportsdb/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "get_last_events", "arguments": {"team_id": "'133604'"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/thesportsdb/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'team_id': "'133604'"}, 'name': 'get_last_events'}},
)
print(resp.json())

get_next_events

Get the next 5 upcoming events for a team. Returns scheduled fixtures with opponents, date, time, and venue. Useful for checking upcoming matches.

ParameterTypeRequiredDescription
team_idstringrequiredNumeric team ID (e.g. '133604' for Arsenal). Use search_teams to find it.
curl -X POST "https://context.gnist.ai/mcp/thesportsdb/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "get_next_events", "arguments": {"team_id": "'133604'"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/thesportsdb/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'team_id': "'133604'"}, 'name': 'get_next_events'}},
)
print(resp.json())

report_feedback

Report a bug, feature request, or general feedback for this data source. Use this when something doesn't work as expected, when you'd like a new feature, or when you have suggestions for improvement. Args: feedback: Describe the issue or suggestion. feedback_type: One of 'bug', 'feature_request', or 'general'.

ParameterTypeRequiredDescription
feedbackstringrequired
feedback_typestringoptional (default: general)
curl -X POST "https://context.gnist.ai/mcp/thesportsdb/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "report_feedback", "arguments": {"feedback": "example"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/thesportsdb/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'feedback': 'example'}, 'name': 'report_feedback'}},
)
print(resp.json())

Common Patterns

Search then retrieve
Use search_teams to find items, then get_team to get full details. This two-step pattern is common for exploring data before drilling down.

FAQ

What data does TheSportsDB (Sports Data) provide?

Sports data — leagues, teams, players, events, and standings from TheSportsDB. It exposes 8 tools: search_teams, get_team, search_players, get_league_table, get_events_by_date, get_last_events, get_next_events, report_feedback.

What do I need to get started?

A Gnist API key (free tier: 100 calls/day). Sign up at https://context.gnist.ai/signup.

What format does the TheSportsDB (Sports Data) API return?

JSON, via either MCP protocol (JSON-RPC 2.0) or REST API.

Next Steps

Related Tutorials