Skip to main content

Python 3 API wrapper for FireServiceRota/BrandweerRooster

Project description

Python: FireServiceRota / BrandweerRooster

Python 3 API wrapper for FireServiceRota and BrandweerRooster


This package allows you to get notified about emergency incidents from and Those are services used by firefighters.

See and for more details.

NOTE: You need a subscription and login account to be able to use it.


pip3 install pyfireservicerota


from pyfireservicerota import FireServiceRotaOAuth, FireServiceRotaOauthError, FireServiceRotaIncidentsListener
import logging
import sys
import json
import time
import threading

_LOGGER = logging.getLogger(__name__)

oauth = FireServiceRotaOAuth(

    token_info = oauth.get_access_token()
except FireServiceRotaOauthError:
    token_info = None

if not token_info:
    _LOGGER.error("Failed to get access token")

wsurl = f"wss://{token_info['access_token']}"

class FireService():

    def __init__(self):

        self._data = None
        self.listener = None
        self.thread = threading.Thread(target=self.incidents_listener)
        self.thread.daemon = True

    def on_incident(self, data):
        _LOGGER.debug("INCIDENT: %s", data)
        self._data = data

    def data(self):
        """Return the current data stored in the provider."""
        return self._data

    def incidents_listener(self):
        """Spawn a new Listener and links it to self.on_incident."""

        _LOGGER.debug("Starting incidents listener")
        self.listener = FireServiceRotaIncidentsListener(url=wsurl, on_incident=self.on_incident)

        while True:

ws = FireService()

while True:

Don't store user credentuals, just the token_info and use below code to refresh it, it will only fetch new token when it has expired. If you want to force a token refresh add True as param to oauth.refresh_acess_token()

oauth = FireServiceRotaOAuth(

    token_info = oauth.refresh_access_token(current_token_info)
except FireServiceRotaOauthError:
    token_info = None

if not token_info:
    _LOGGER.error("Failed to get access token")

if token_info != current_token_info:
    _LOGGER.error("Got new token, store it")

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyfireservicerota-0.0.11.tar.gz (4.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page