Auth introduction
In order to use the pre-match data service, you have to authenticate yourself. This is done by sending a POST request to the authentication endpoint with your login and password. The response will contain an access token that you can use to authenticate your requests to the other endpoints.
The base endpoint for authentication is https://skill-rating-service.bayesesports.com/api/auth
https://skill-rating-service.bayesesports.com/api/auth
Getting a token
To use the API you will need a valid login and password. These are the same credentials you would use to enter the Web UI.
In this section, we will be using Python's request library to demonstrate how to use the Data Portal APIs but there are alternatives:
- using command-line tools like curl, wget or HTTPie, suitable for quick testing
- using API-clients like Postman or Insomnia, perfect for exploring API endpoints and thorough query testing
With your username
and password
, simply do:
r = requests.post(f'https://skill-rating-service.bayesesports.com/api/auth', json={'username': username, 'password': password})
token = r.json()['access_token']
As the expiresIn
response field indicates, the access token accessToken
is valid for 24 hours (or 86400 seconds). After this duration you have to authenticate again.
📝 Tip
Issuing a new access token is a slow process. Code that requests a new token before every API call will work much slower than code that stores the token and only refreshes it on expiry. Requesting too many tokens may also be treated as suspicious behavior by the authentication server and potentially result in IP blocks.
We currently do not offer an endpoint to refresh a token.
Using the token
The token you obtained in the previous step should be included in the header of every request you make to the API.
An example usage where you want the pre-match probabilities for a match between two teams in a BO5 might look like this:
# Create the header to use from here on in every request:
headers = {'Authorization': f'Bearer {token}'}
# Request a BO5 pre-match prediction for two teams:
team1_perid, team2_perid = <PLEASE PUT THE TEAM PERIDS HERE>
query_string = f'team1_perid={team1_perid}&team2_perid={team2_perid}&best_of=5'
r = requests.get(f'{base_url}/api/prematch_proba?{query_string}', headers=headers)
r.raise_for_status()
outcomes = r.json()
For information on which endpoints are available and what options they offer, please see the sidebar on the left.