To get the statistics of all players in Indian Premier League. As needed such data for one of the project and there was no suitable api found for the purpose, so decided to create one, and as it was created, shared too, if required by anybody. The data is updated after each match. The api is developed by scraping data from official website of https://www.iplt20.com, and is latest by the statistics available there. The data is https://www.iplt20.com property and all rights reserved with them.
Currently the api is useful primarily for only getting a player's data from all seasons combined. And there are innumerous other stuffs possible to be done. But as the data belongs to the concerned authority, and it may or may not be adequate to access it without proper permissions and consent. Still, if you know more of the law and if it's alright to be so, contributions are welcomed to make it bigger.
You can visualize the api in action here: https://iplt20-stats.herokuapp.com (Please be patient for first load time, lazy dyno 💤 needs some time to wake up 😉).
You can read docs and try the api here: https://documenter.getpostman.com/view/10557860/TzJsedV4
Follow these steps to run the code locally:
- Clone this repository.
- Run
composer install
- Run
yarn install
- Create a file called .env.local at the root of the project
- Add these environment variables in .env.local:
APP_ENV=dev
DATABASE_URL="mysql://db_user:[email protected]:3306/db_name?serverVersion=5.7"
Replace your database credentials here. Reference
- Run these commands in terminal:
php bin/console make:migration
php bin/console doctrine:migrations:migrate
If you get any error in some query while running the command. Manually comment out that query in migrations folder. This will setup the local database with all tables.
- Run
symfony serve -d
- Run
yarn watch
- The project will start running on the local server.
Docs :: Postman
Provides the list of squads with their name and id.
https://iplt20-stats.herokuapp.com/api/squads-list
Method: 'GET'
No params required for the request
Json array of objects
Key | Value |
---|---|
id | Squad-id |
name | Squad-name |
http://iplt20-stats.herokuapp.com/api/squad-details/{id}
Method: 'GET'
The squad-id is passed in the url
Json object with squad details and array of players in the squad
Key | Value |
---|---|
squad | Object with squad details. |
players | Array of player objects. |
http://iplt20-stats.herokuapp.com/api/player-details/{id}
Method: 'GET'
The player-id is passed in the url
Json object with player details
Key | Value |
---|---|
player_id | Player-id |
player_name | Player-name |
team_id | Team-id |
image_url | Player image url |
matches | Total number of matches played |
not_outs | Total number of times player remained not out |
runs | Total number of runs scored |
highest_score | Highest career score in one inning |
batting_average | Batting average (runs scored per wicket) |
strike_rate | Strike rate (runs scored per 100 ball) |
hundreds | Total Hundreds scored |
fifties | Total Fifties scored |
sixes | Total Sixes hit |
catches | Total catches taken |
overs | Total overs bowled |
wickets | Total wickets taken |
bowling_average | Bowling average (runs conceded per wicket) |
economy | Bowling economy (runs conceded per over) |
four_wickets | Total four wickets haul |
http://iplt20-stats.herokuapp.com/api/all-players-list
Method: 'POST'
Parameters are passed as Json Object in the body.
Note: No parameter is mandatory, and will take default value if not defined.
Param | Value acceptable | Default Value | Details |
---|---|---|---|
start_range | Integer value | 0 | This is taken as the offset value for the total result. |
data_count | Integer value | 30 | This is the number of results requested. Maximum possible value is 30. It will be taken as 30 automatically if requested more than it. If number of results found/remained are less than data_count with respect to start_range , lesser data count of results will be sent as response. |
team_id | Integer value | null | Id parameter to get results for a particular team as per id passed. |
sort_attr | "matches" | "not_outs" | "runs" | "hundreds" | "fifties" | "sixes" | "catches" | "overs" | "wickets" | "four_wickets" | "highest" | "batting_average" | "bowling_average" | "strike_rate" | "economy" | null | The parameter with which the data is desired to be sorted by. |
order | "asc" | "desc" | desc | asc means ascending order and desc means descending order with respect to sort_attr |
Json array of objects with player details as described above in player details.