TheSportsDB

TheSportsDB

Sports & Fitness

Crowd-Sourced Sports Data and Artwork. An open, crowd-sourced database of sports artwork and metadata with a free API. The content here is only possible thanks to the hard work of our users..

Visit APIπŸ” Alternatives

πŸ“š Documentation & Examples

Everything you need to integrate with TheSportsDB

πŸš€ Quick Start Examples

TheSportsDB Javascript Examplejavascript
// TheSportsDB API Example
const response = await fetch('https://www.thesportsdb.com/api.php', {
    method: 'GET',
    headers: {
        'Content-Type': 'application/json'
    }
});

const data = await response.json();
console.log(data);

A Brief Guide to The SportsDB API

TheSportsDB API is an open database of sports teams, leagues, and events. It provides programmatic access to detailed information on various sports, including soccer, basketball, baseball, ice hockey, and more. In this guide, we will go through the different APIs offered by TheSportsDB and write some sample code in JavaScript to show how to use them.

Prerequisites

To use the API, you will need to sign up for a free API key. You can sign up at https://www.thesportsdb.com/api.php.

Available APIs

  1. Search Teams API
  2. Lookup Team API
  3. Search Events API
  4. Lookup Event API

Search Teams API

The Search Teams API allows you to search for sports teams based on a given keyword. You can specify which sports (soccer, basketball, etc.) to search in. Here's how to use the API in JavaScript:

const apiKey = 'your-API-key';
const keyword = 'lakers';
const sport = 'basketball';

fetch(`https://www.thesportsdb.com/api/v1/json/${apiKey}/searchteams.php?t=${keyword}&s=${sport}`)
  .then(response => response.json())
  .then(data => console.log(data.teams))
  .catch(error => console.error(error));

In this code, we use the fetch function to make a GET request to the API endpoint. We pass our API key, the keyword we want to search, and the sport to search in as query parameters. We then use the then method to extract the JSON data from the response and log the list of teams to the console.

Lookup Team API

The Lookup Team API allows you to retrieve detailed information on a specific sports team. You can specify which team to look up by providing its ID. Here's how to use the API in JavaScript:

const apiKey = 'your-API-key';
const teamId = '134862';

fetch(`https://www.thesportsdb.com/api/v1/json/${apiKey}/lookupteam.php?id=${teamId}`)
  .then(response => response.json())
  .then(data => console.log(data.teams[0]))
  .catch(error => console.error(error));

In this code, we use the fetch function to make a GET request to the API endpoint. We pass our API key and the team ID as query parameters. We then use the then method to extract the JSON data from the response and log the team object to the console.

Search Events API

The Search Events API allows you to search for sports events based on a given keyword. You can specify which sports (soccer, basketball, etc.) to search in. Here's how to use the API in JavaScript:

const apiKey = 'your-API-key';
const keyword = 'lakers';
const sport = 'basketball';

fetch(`https://www.thesportsdb.com/api/v1/json/${apiKey}/searchevents.php?e=${keyword}&s=${sport}`)
  .then(response => response.json())
  .then(data => console.log(data.events))
  .catch(error => console.error(error));

In this code, we use the fetch function to make a GET request to the API endpoint. We pass our API key, the keyword we want to search, and the sport to search in as query parameters. We then use the then method to extract the JSON data from the response and log the list of events to the console.

Lookup Event API

The Lookup Event API allows you to retrieve detailed information on a specific sports event. You can specify which event to look up by providing its ID. Here's how to use the API in JavaScript:

const apiKey = 'your-API-key';
const eventId = '602385';

fetch(`https://www.thesportsdb.com/api/v1/json/${apiKey}/lookupevent.php?id=${eventId}`)
  .then(response => response.json())
  .then(data => console.log(data.events[0]))
  .catch(error => console.error(error));

In this code, we use the fetch function to make a GET request to the API endpoint. We pass our API key and the event ID as query parameters. We then use the then method to extract the JSON data from the response and log the event object to the console.

Conclusion

TheSportsDB API provides a rich source of information for sports enthusiasts and developers alike. In this guide, we have shown some examples of how to use the different APIs available, but there are many more endpoints you can explore. For a full list of APIs, check out https://www.thesportsdb.com/api.php. Happy coding!

How to Get a TheSportsDB API Key

TheSportsDB gives you two ways in. For quick testing and hobby projects, use the free public test key 123 with the v1 JSON API β€” no signup needed:

curl "https://www.thesportsdb.com/api/v1/json/123/searchteams.php?t=Arsenal"

The free test key works but is limited: fewer search results, some methods disabled, and it's shared, so it isn't meant for production.

For a dedicated, production-ready key plus the newer v2 API:

  1. Create a free account at https://www.thesportsdb.com/.
  2. Subscribe to Premium (currently about $9/month β€” check the site for current pricing).
  3. Find your personal API key on your user profile page.

Use your personal key in place of 123 in the v1 URL. The v2 API lives at https://www.thesportsdb.com/api/v2/json/ and authenticates with your key sent in the X-API-KEY request header. Because the 123 key is heavily shared and rate limited, switch to a personal key before shipping anything that depends on TheSportsDB. Full method list: https://www.thesportsdb.com/documentation.

Explore More

Best TheSportsDB alternatives (2026)Best Sports & Fitness APIs

Related APIs in Sports & Fitness