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);

Exploring TheSportsDB Public API

TheSportsDB offers a public API for accessing information on popular sports events, teams, and players. In this article, we will explore the available endpoints of the API and provide JavaScript code examples.

To use the API, you will need an API key, which can be obtained for free by signing up on their website.

Endpoints

TheSportsDB API offers several endpoints to retrieve data on sports events, leagues, teams, and players. Here are some of the popular endpoints:

Events Endpoint

This endpoint allows you to retrieve data on upcoming and past sports events.

const url = 'https://www.thesportsdb.com/api/v1/json/1/eventspastleague.php?id=4328&country=USA';

fetch(url)
  .then(response => response.json())
  .then(data => console.log(data.events));

Leagues Endpoint

This endpoint allows you to retrieve data on different sports leagues.

const url = 'https://www.thesportsdb.com/api/v1/json/1/all_leagues.php';

fetch(url)
  .then(response => response.json())
  .then(data => console.log(data.leagues));

Teams Endpoint

This endpoint allows you to retrieve data on different sports teams.

const url = 'https://www.thesportsdb.com/api/v1/json/1/lookup_all_teams.php?id=4328';

fetch(url)
  .then(response => response.json())
  .then(data => console.log(data.teams));

Players Endpoint

This endpoint allows you to retrieve data on players in different sports teams.

const url = 'https://www.thesportsdb.com/api/v1/json/1/lookup_all_players.php?id=133602';

fetch(url)
  .then(response => response.json())
  .then(data => console.log(data.player));

Conclusion

Using TheSportsDB public API, you can access a wealth of information on popular sports events, leagues, teams, and players. By exploring the endpoints provided by the API, you can build powerful applications that cater to the needs of sports fans.

📊 30-Day Uptime History

Daily uptime tracking showing online vs offline minutes

Jan 8Jan 10Jan 12Jan 14Jan 16Jan 18Jan 20Jan 22Jan 24Jan 26Jan 28Jan 30Feb 1Feb 3Feb 604008001440Minutes
Online
Offline

Related APIs in Sports & Fitness