📅  最后修改于: 2023-12-03 15:34:04.487000             🧑  作者: Mango
Are you a sports enthusiast looking for a way to get real-time sports data, scores, schedules, and news articles right at your fingertips? Python Sports API is here to fulfill your needs!
Our API provides comprehensive data on various sports such as football, basketball, baseball, tennis, and many more! It's easy to use, efficient and provides data in real-time.
To use our API, you'll first need to sign up for an API key. Once you have your API key, you can access data for different sports and leagues by sending HTTP requests to our API endpoints.
Here's an example of how you can use our API to get live scores for a soccer match:
import requests
url = "https://api.sportradar.com/soccer/v2/eu/matches/092c5d5eeefb2c822e02e7af9daebed9/live_summary.json?api_key=YOUR_API_KEY"
response = requests.get(url)
if response.status_code == 200:
match_data = response.json()
home_team = match_data['home_team']['name']
away_team = match_data['away_team']['name']
home_score = match_data['home_score']
away_score = match_data['away_score']
print(f"Score: {home_team} {home_score} - {away_score} {away_team}")
else:
print("Error retrieving data from API.")
In this example, we're sending a GET request to the API endpoint for live summary data for a soccer match. We're then parsing the JSON response and printing the current score of the match.
Our API currently offers the following endpoints:
/football/v2/
: Provides stats, scores, and more for football leagues such as NFL, NCAA, CFL, and more.
/basketball/v2/
: Provides stats, scores, and more for basketball leagues such as NBA, NCAA, Euroleague, and more.
/baseball/v2/
: Provides stats, scores, and more for baseball leagues such as MLB, MiLB, and more.
/tennis/v2/
: Provides stats, scores, and more for professional tennis matches and tournaments.
For more information on how to use our API, check out our official documentation.
Python Sports API is the best solution for obtaining real-time sports data in a user-friendly and efficient manner. Sign up for an API key now and start accessing world-class sports data!