I created this project to learn how to use GraphQL with python. For this, I used data from the game Rocket League (Team, Region, Player) available via the site: https://liquipedia.net/rocketleague and their api.
First you need to install the dependencies:
pip install -r requirements.txt
After this, you just need to do the following:
export FLASK_APP=app.py
flask run
And go to http://localhost:5000/
In order to get the data, i use the api of the Liquipedia Rocket League Website and you can see the limitation and TOS of the API here :
https://liquipedia.net/api-terms-of-use
You can see the function to scrap the teams in the test_scrap.py file.
The database is a sqlite3 database.In order to add the data to the database, you can use the script db_to_add.py or with a tool like sqlitebrowser.
If you want to get all the teams in the Sqlite database, you can use the following query:
query {
listAllTeams{
teams {
id
region
name
player_one
player_two
player_three
player_sub
coach
}
}
}
If you want to get information about a team thanks to the name of the team.Use the following query:
query {
getTeam_ByName(name: "NRG"){
team {
id
region
name
player_one
player_two
player_three
player_sub
coach
}
}
}
If you want to get information about all the teams in a region.Use the following query:
query {
getTeam_ByRegion(region: "EU"){
teams {
id
region
name
player_one
player_two
player_three
player_sub
coach
}
}
}
If you want to get all the regions in the Sqlite database, you can use the following query:
query {
listAllRegions {
region {
name
}
}
}
If you want to get all the player (Only a few right now ) in the Sqlite database, you can use the following query:
query {
listAllPlayers {
player {
id
name
nationality
born
status
team
winningmonney
otherpseudo
pseudo
}
}
}
If you want to get information about a player thanks to the name of the player.Use the following query:
query {
getPlayer_ByName(name: "Axel Touret") {
player {
id
name
nationality
born
status
team
winningmonney
otherpseudo
pseudo
}
}
}
If you want to get information about a player thanks to the pseudo of the player.Use the following query:
query {
getPlayer_ByPseudo(pseudo:"FabiDerKrosse"){
player {
id
name
nationality
born
status
team
winningmonney
otherpseudo
pseudo
}
}
}
If you want to get all the Transfers listed in the Sqlite database, you can use the following query:
query {
listAlltransferts {
success
errors
transfert {
id
players
oldteam
newteam
date
}
}
}
If you want to get all the matches in the Sqlite database, you can use the following query:
query {
listAllMatches {
success
errors
matche {
id
team_un
team_deux
countdown
score
}
}
}