I am trying to fetch data from sorare using their GraphQL API. I have managed to find the pattern to make a query as follows:
import requests
# Define the GraphQL query
query = """
{
player(slug: "nico-schlotterbeck") {
firstName
lastName
position
cardPositions
id
slug
activeClub {
name
}
age
so5Scores(last: 5) {
score
}
}
}
"""
# Define the Sorare GraphQL API URL
api_url = "https://api.sorare.com/graphql"
# Make a POST request to the Sorare GraphQL API
response = requests.post(api_url, json={"query": query})
# Check if the request was successful
if response.status_code == 200:
# Parse the JSON response
data = response.json()
# Extract player information
player_data = data["data"]["player"]
# Print the player information
print("Player Name:", player_data["firstName"], player_data["lastName"])
print("Position:", player_data["position"])
print("Card Positions:", player_data["cardPositions"])
print("ID:", player_data["id"])
print("Slug:", player_data["slug"])
print("Active Club:", player_data["activeClub"]["name"])
print("Age:", player_data["age"])
print("Last 5 SO5 Scores:")
for score_data in player_data["so5Scores"]:
print(" - Score:", score_data["score"])
else:
print("Failed to retrieve data. Status code:", response.status_code)
The problem is, I want to fetch more information most importantly player’s current price or market value. Can anyone please suggest what should be the query for that?
I searched a lot but could not find any suitable source for this.
I tried using currentPrice
in the query but it returns error.