How to use the BeatTheBookie data service?

The BeatTheBookie data service is provided as a REST Api. So everybody is able to use the favoured programming language to get the data. All examples I provide, will be in Python.

Authentication

Even if the service is free for everybody, I need to keep control how many people access the service how often. I don’t want a bad suprise, if suddenly the AWS costs explode. That’s why I decided to secure the service by API keys. Everybody, who wants to access the service, just need to contact me via the blog or @Mo_Nbg. By using the API key as a request header, you authenticate for the BeatTheBookie data service.

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' : '[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 data

Getting the data is fairly easy. The BeatTheBookie data service provides multiple REST Api endpoints e.g. for different predictive models. After getting an API key you are able to access all endpoints and get the data. You can find multiple examples at the GitHub repository.

import requests
import pandas as pd
import json


#endpoint for ZIP poisson model
url = 'https://data-service.beatthebookie.blog/zip-poisson-model'

# 2. bundesliga
params = {'division':'2. Bundesliga'}

#create header information containing the API Key
my_headers = {'x-api-key' : '[API key]'}

#Call HTTP get method for endpoint and provide header information
response = requests.get(url, headers=my_headers,  params=params)

df_predictions = pd.read_json(response.content)

print(df_predictions)