Bosch e-bike connect - fetch statistics with Python

I’m a tinkerer. I like to experiment, break stuff, improve. I like to analyze how things work in general. When I was a kid, this often resulted in a shock for my mother whenever she discovered I completely disassembled something. I think I was five years old when I decided to take apart my bicycle. At the age of fourteen, when the first computer entered our house, it probably took two hours and the thing was in pieces on the floor. Luckily, for me, I was able to re-assemble the system.

When I received my e-bike yesterday (Sparta d-burst energy metb) one of the first things I got interested in is how the portal of Bosch contains all the Kiox computer data. I’m no data scientist but I immediately felt the urge to somehow extract that information from the portal.

Twenty minutes later and I hacked together a Python script to login on the website, grab the authentication token and request the statistics. I have no clue yet what I actually want to do with this data. I haven’t logged any activities yet, so perhaps I need to further adapt the script to also fetch your activity data.

Perhaps I can migrate the activity data together with weather data and do some statistics / analysis on how often there was rainfall during my commutes to work for instance. To be continued!

Python script to fetch the Bosch e-bike connect data

import random, requests

    'login': '',
    'statistics': ''

    'username': '',
    'password': 'example_password'

class BoschEbike:
    data = {}

    def __init__(self):
        self.current_session = requests.Session()

    def login(self):
        payload = {
            'username': BOSCH_CREDENTIALS['username'],
            'password': BOSCH_CREDENTIALS['password'],
            'rememberme': 'true'
        }['login'], json=payload)
        remember_cookie_token = self.current_session.cookies['REMEMBER']

    def fetch_data(self, remember_cookie_token):
        headers = {
            'cookie': 'REMEMBER=' + remember_cookie_token,
            'referer': '',
            'user-agent': str(random.random())[3:],
            'authority': '',
            'protect-from': 'CSRF'
        } = self.current_session.get(BOSCH_URLS['statistics'], headers=headers).json()

    def get_statistics(self):
        print (

bosch_ebike = BoschEbike()
statistics = bosch_ebike.get_statistics()


Example output

    "current_month": {
        "month": 7,
        "distance": 0,
        "average_speed": 0.0,
        "calories_burned": 0,
        "elevation_gain": 0
    "last_month": {
        "month": 6,
        "distance": 0,
        "average_speed": 0.0,
        "calories_burned": 0,
        "elevation_gain": 0
    "total_statistics": {
        "distance": 0,
        "elevation_gain": 0