Introduction

Welcome to the Sports Statistics API Documentation! This API is designed to provide free and accessible sports data to hobbyists, students, and anyone who cannot afford paid sports APIs. Whether you are building a sports application, working on a school project, or learning to handle APIs in your frontend projects, this API offers a comprehensive and easy-to-use interface for accessing up-to-date sports information.

Github Repo πŸ”—

πŸ‘¨πŸΌβ€πŸ’» Feel free to contribute and give it ⭐

https://github.com/cryptomafiaPB/yes-sports-api

Overview

The Sports Statistics API allows developers to retrieve information about different sports, teams, and players. The data is scraped from the Cricbuzz website and includes both historical and real-time data. While the current focus is on cricket, the API will soon be expanded to include other sports such as football, kabaddi, and basketball.

Key Benefits:

Authentication

This API does not require any form of authentication. You can start making requests immediately without needing API keys, tokens, or any other credentials. This approach simplifies the process and allows you to focus on integrating the data into your applications.

Endpoints

This API does not require any form of authentication. The Sports Statistics API provides several endpoints to access detailed information about sports, teams, and players. Below is a detailed explanation of each endpoint, including the structure, parameters, and example responses.

Base URL

All API requests are made to the following base URL:

https://yessports.vercel.app/api/v1

1. Sports endpoint

Endpoint:`/[sports]`

This endpoint returns detailed information about a specific sport, including a description, rules, history, and a list of teams.

Parameters:

`[sports]`: The sports name (only accepts `cricket`, `football`, `kabaddi`, `basketball`).

Example Request:

curl -X GET "https://yessports.vercel.app/api/v1/cricket"

Example Responce:

{
  "sport": {
    "id": "2",
    "name": "Cricket",
    "description": "Cricket is a bat-and-ball game played between two teams of eleven players each on a cricket field. It is one of the most popular sports in the world, particularly in countries like India, Australia, England, and Pakistan.",
    "rules": "Cricket involves two phases: batting and bowling/fielding. The batting team tries to score runs by hitting the ball while the bowling team tries to dismiss the batsmen and restrict runs.",
    "history": "Cricket originated in England in the late 16th century and has since become widely popular, especially in former British colonies and beyond. It is known for its rich history and traditions.",
    "teams": [
      "India",
      "Afghanistan",
      "Ireland",
      "Pakistan",
      "Australia",
      "Sri Lanka",
      "Bangladesh",
      "England",
      "West Indies",
      "South Africa",
      "Zimbabwe",
      "New Zealand"
    ]
  }
}

2. Teams endpoint

Endpoint:`/[sports]/[team]`

This endpoint returns the list of players for a specific team within a given sport.

Parameters:

`[sports]`: The sports name (only accepts `cricket`, `football`, `kabaddi`, `basketball`).

`[team]`: The team name (case-sensitive, first letter of each word capitalized).

Example Request:

curl -X GET "https://yessports.vercel.app/api/v1/cricket/India"

Example Responce:

{
  "team": "India",
  "teamNum": 2,
  "playersList": [
    {
      "name": "Virat Kohli",
      "number": "1413"
    },
    {
      "name": "Rohit Sharma",
      "number": "576"
    },
    {
      "name": "Shikhar Dhawan",
      "number": "1446"
    },
    {
      "name": "Shubman Gill",
      "number": "11808"
    },
    {
      "name": "Shreyas Iyer",
      "number": "9428"
    },
    {
      "name": "Manish Pandey",
      "number": "1836"
    },
    {
      "name": "Mayank Agarwal",
      "number": "2195"
    },
    {
      "name": "Prithvi Shaw",
      "number": "12094"
    },
    {
      "name": "Cheteshwar Pujara",
      "number": "1448"
    },
    {
      "name": "Ajinkya Rahane",
      "number": "1447"
    },
    {
      "name": "Ruturaj Gaikwad",
      "number": "11813"
    },
    {
      "name": "Hardik Pandya",
      "number": "9647"
    },
    {
      "name": "Hanuma Vihari",
      "number": "8424"
    },
    {
      "name": "Ravindra Jadeja",
      "number": "587"
    },
    {
      "name": "Ravichandran Ashwin",
      "number": "1593"
    },
    {
      "name": "KL Rahul",
      "number": "8733"
    },
    {
      "name": "Sanju Samson",
      "number": "8271"
    },
    {
      "name": "Wriddhiman Saha",
      "number": "1465"
    },
    {
      "name": "Rishabh Pant",
      "number": "10744"
    },
    {
      "name": "Mohammed Shami",
      "number": "7909"
    },
    {
      "name": "Jasprit Bumrah",
      "number": "9311"
    },
    {
      "name": "Kuldeep Yadav",
      "number": "8292"
    },
    {
      "name": "Yuzvendra Chahal",
      "number": "7910"
    },
    {
      "name": "Navdeep Saini",
      "number": "9715"
    },
    {
      "name": "Shardul Thakur",
      "number": "8683"
    },
    {
      "name": "Umesh Yadav",
      "number": "1858"
    },
    {
      "name": "Mohammed Siraj",
      "number": "10808"
    }
  ]
}

3. Player Details endpoint

Endpoint:`/[sports]/[team]/[playerNumber]`

This endpoint returns detailed information about a specific player, including personal info, statistics, and profile picture URL.

Parameters:

`[sports]`: The sports name (only accepts `cricket`, `football`, `kabaddi`, `basketball`).

`[team]`: The team name (case-sensitive, first letter of each word capitalized).

`[playerNumber]`: The unique number associated with the player

Example Request:

curl -X GET "https://yessports.vercel.app/api/v1/cricket/India/1413"

Example Responce:

{
  "playerName": "Virat Kohli",
  "nationalTeam": "India",
  "profilePicUrl": "https://static.cricbuzz.com/a/img/v1/152x152/i1/c332891/virat-kohli.jpg",
  "personalInfo": {
    "born": "Nov 05, 1988 (35 years)",
    "birthplace": "Delhi",
    "height": "5 ft 9 in (175 cm)",
    "role": "Batsman",
    "battingStyle": "Right Handed Bat",
    "bowlingStyle": "Right-arm medium"
  },
  "description": "A spunky, chubby teenager with gelled hair shot to fame after leading India to glory in the Under-19 World Cup at Kuala Lumpur in early 2008. In an Indian team filled with saint-like icons worthy of their own hagiographies, Virat Kohli, with his most un-Indian, 'bad-boy' intensity, would clearly be an outcast.Kohli's thirst for runs showed no signs of slowing down as he looted a small matter of 973 runs during the 2016 edition of the Indian Premier League, the most (by far) by any batsman in the history of the tournament However, it isn't beyond Kohli to prove his critics wrong yet again, as he continues to take criticism on his stride, setting new standards for modern batsmanship.Alas, all this didn't translate into a title triumph - one that has kept Kohli and Bangalore waiting so far (As of March 2023).",
  "teams": "India, Delhi, India Red, India U19, Royal Challengers Bengaluru, Board Presidents XI, North Zone, Indians, India A, Asia XI",
  "iccRankings": {
    "batting": {
      "Test": "9",
      "ODI": "3",
      "T20": "48"
    },
    "bowling": {
      "Test": "--",
      "ODI": "3",
      "T20": "48"
    }
  }
}

Error Handling

When using the Sports Statistics API, you may encounter various errors. Properly handling these errors in your application is crucial for providing a smooth user experience. This section outlines the common errors you may encounter and how to handle them.

Common Errors

Resource Not Found (200): This error occurs when the requested resource does not exist. It could be due to an incorrect sport name, team name, or player number.

Example error Responce:

{
  "error": "Resource not found"
}

Server error (500): This error indicates that there is a problem with the server. It could be due to various reasons such as server overload, unexpected conditions, or other issues.

Example error Responce:

{
  "error": "Server error"
}

Handling Errors

To handle these errors effectively, your application should check for these specific status codes and display appropriate messages to the user.

Example of Handling Errors in JavaScript:

JavaScript Code

Contact

We would love to hear from you! Whether you have questions, feedback, or need support, feel free to reach out to us. Here’s how you can get in touch:

Email

For any inquiries, support, or collaboration opportunities, please email us at:

πŸ“§ john853043@gmail.com

Github

If you encounter any issues, have feature requests, or want to contribute to the project, please use the GitHub repository:

πŸ”— [GitHub Repository URL]
Issues: Report bugs or request features via the GitHub Issues page.
Pull Requests: Feel free to fork the repository, make your changes, and submit a pull request. Check out our Contributing Guide for more details.

Social media

Stay updated with the latest news, updates, and discussions:

Twitter :@Pranavbagal9

Note : All the data belongs to cricbuzz.com and they have the right to take legal actions against use of their data. Please do not use it for commercial purposes. This project is only for educational purposes.

Copyright@2024