research/uefa/uefa_api/uefa_match_api.py
2024-10-15 10:41:25 +02:00

40 lines
1.1 KiB
Python

# %%
import requests
import json
prod_url = 'https://uefadigitalapi.developer.azure-api.net'
prod_primary_key = '9b849959b7aa40b9b1f966254c22fc6e'
prod_secondary_key = '116b2865175141e6955e6c83fe4651ae'
pre_url = 'https://uefadigitalapipre.developer.azure-api.net'
pre_primary_key = 'b6bdd59422614fa9932c03fb16666067'
pre_secondary_key = '4e61efa534f94f38a4c96ba9bc00f444'
headers = {"Cache-Control":"no-cache","Ocp-Apim-Subscription-Key":prod_primary_key}
# %%
competitionId = 1 # Champions League
seasonYear = 2025
uefa_match_url = f"https://api.digital.uefa.com/match/v5/matches?offset=0&limit=500&status=FINISHED&order=DESC&competitionId={competitionId}&seasonYear={seasonYear}&seasonsRange=ALL&phase=ALL"
res = requests.get(uefa_match_url, headers=headers)
json.dump(res.json(), open("uefa_match.json", "w"))
# # %%
# %%
"""
Match live score
Try it
Provide details about the score of a collection of matches given a number of conditions.
"""
uefa_match_url = f"https://api.digital.uefa.com/match/v5/livescore&competitionId={competitionId}"
res = requests.get(uefa_match_url, headers=headers)
res.json()
# %%