The BeatTheBookie data service was created with the goal of sharing my data for free, allowing anyone to dive in and explore without the hassle of dealing with data integration from multiple sources. Recently, I made some updates and adjustments to the service based on user feedback, with the primary aim of enhancing the overall user experience. In this post, I’ll walk you through these improvements and show you how you can easily consume data from the BeatTheBookie data service with a few examples.
Authentification
Once you’ve subscribed and received your API key, the first step is to test your connection and ensure that the authentication is working correctly. To do this, you can use the “auth-test” endpoint, which allows you to verify the connection and confirm that everything is set up properly.
import requests
#endpoint for ZIP poisson model
url = 'https://data-service.beatthebookie.blog/auth-test'
#create header information containing the API Key
my_headers = {'x-api-key' : '[your API key]'}
#Call HTTP get method for endpoint and provide header information
response = requests.get(url, headers=my_headers)
#print response
print(response.content)
Which divisions and seasons are available?
One of the recent changes is that you now need to filter by division and season for each data endpoint. This adjustment was necessary because the historical data had grown too large, which was causing errors. To help you with the filtering process, I’ve introduced two new endpoints: /seasons and /divisions. These endpoints allow you to retrieve all possible values for each filter.
However, it’s important to note that not every historical data endpoint provides data for all season values. So, when making requests, be sure to check which seasons are available for each specific endpoint.
import requests
#endpoint for ZIP poisson model
url = 'https://data-service.beatthebookie.blog/seasons'
#create header information containing the API Key
my_headers = {'x-api-key' : '[your API key]'}
#Call HTTP get method for endpoint and provide header information
response = requests.get(url, headers=my_headers)
#print response
print(response.content)
Getting historic data
The historical data includes statistics and odds for over 30,000 matches, making it an ideal resource for anyone looking to work with data from multiple sources and build their own models. All team names across the various data providers have been aligned to ensure consistency. As the volume of data continued to grow, it became necessary to introduce the season as an additional parameter to help manage the data more effectively.
import requests
#endpoint for ZIP poisson model
url = 'https://data-service.beatthebookie.blog/data'
# Bundesliga
params = {'division':'Bundesliga','season': '2020_2021'}
#create header information containing the API Key
my_headers = {'x-api-key' : '[your API key]'}
#Call HTTP get method for endpoint and provide header information
response = requests.get(url, headers=my_headers, params=params)
print(response.content)
Getting BeatTheBookie base model data
If you already have your own model and want to compare it to a basic model, the various model endpoints are the way to go. These endpoints provide both historical predictions and upcoming predictions for all of my base models. To ensure smooth functionality and prevent errors, the season parameter is now also required for these endpoints.
import requests
#endpoint for ZIP poisson model
url = 'https://data-service.beatthebookie.blog/zip-poisson-model'
# bundesliga
params = {'mode':'hist','division':'Bundesliga','season': '2020_2021'}
#create header information containing the API Key
my_headers = {'x-api-key' : '[your API key]'}
#Call HTTP get method for endpoint and provide header information
response = requests.get(url, headers=my_headers, params=params)
print(response.content)
For more detailed documentation about the different endpoints, you can visit the following link: BeatTheBookie Data Service Endpoints.
If you have further questions, feel free to leave a comment, contact me (contact@beatthebookie.com) or join the Discord Server.
