← OWStats for Twitch

OWStatsfor Twitch

A small Python bot that sits in your Twitch chat and answers questions about ranks, heroes and today's wins. This guide takes you from zero to a running bot in about 15 minutes.

15chat commands
~15 minsetup time
Freeno paid services
1

Install Python

The bot is written in Python, so you need Python 3.10 or newer. Download it from python.org/downloads and run the installer.

On Windows, tick “Add python.exe to PATH” before clicking Install Now. If you forget it, the terminal won't find Python.

To check it worked, open a terminal (Windows: press Win, type cmd, press Enter) and type:

Type this and press Enterpython --version
What you should see
> python --version
Python 3.12.4
2

Get the bot files

Download owstatsbot.zip and unzip it, for example on your desktop. You get a folder called owstatsbot with four files:

FileWhat it is
owstatsbot.pyThe bot itself
requirements.txtThe two Python packages the bot needs
.env.exampleSettings template you'll fill in during step 4
setup-guide.htmlThis guide

Open a terminal in the bot folder

A terminal is a black window where you type commands. The easiest way to open one directly in the right folder:

  1. Open the owstatsbot folder in File Explorer, the one with owstatsbot.py inside.
  2. Click once into the address bar at the top, where the folder path is shown. The path turns blue.
  3. Type cmd (this replaces the blue path) and press Enter.
  4. A black window opens. It's already in the right folder: the line ends with \owstatsbot>.
Loops every few seconds. Windows 10 and 11 look a little different, but the address bar is always at the top of the folder window.

On a Mac: open the Terminal app, type cd followed by a space, drag the owstatsbot folder into the Terminal window and press Enter.

Then install the packages:

Type this and press Enterpip install -r requirements.txt
What you should see
> pip install -r requirements.txt
Collecting aiohttp>=3.9 ...
Collecting python-dotenv>=1.0 ...
Successfully installed aiohttp python-dotenv
3

Bot account and token

Create a bot account

Create a second Twitch account for the bot, for example my_ow_bot. That way the answers show up under the bot's name instead of yours. Using your own streamer account also works if you prefer, but I'd recommend a separate account to be on the safe side: if the token ever leaks, only the bot account is affected, not your channel.

Generate an access token

Log in with the bot account and generate a chat token on twitchtokengenerator.com: choose “Bot Chat Token” and confirm with the bot account. It needs the scopes chat:read and chat:edit.

You get three values. The bot only needs the access token. Keep the refresh token and client ID somewhere safe for later.

Never show the access token on stream or send it to anyone. Whoever has it can write in chat as your bot. If it ever leaks, generate a new one.

4

Fill in the .env file

Make a copy of .env.example and rename it to exactly .env (no other name, no .txt at the end). Open it in a text editor such as Notepad and fill in the four highlighted lines:

.env
# Access token of the bot account (scopes: chat:read and chat:edit)TWITCH_TOKEN=oauth:a1b2c3d4e5f6... # Name of the Twitch account the bot chats withTWITCH_BOT_NAME=my_ow_bot # Channel the bot should join (without #)TWITCH_CHANNEL=your_channel_name # Streamer's BattleTagBATTLETAG=Player#1234 # OptionalPLATFORM=pcCOOLDOWN_SECONDS=10GAMEMODE=competitiveREGION=europe
Write oauth: directly followed by your access token, without spaces. Leaving out oauth: also works; the bot adds it.
SettingWhat to enter
TWITCH_TOKENThe access token from step 3
TWITCH_BOT_NAMEThe bot account's username (the account you generated the token with)
TWITCH_CHANNELYour channel name, the part after twitch.tv/
BATTLETAGYour BattleTag including the number, with exact upper and lower case
PLATFORMpc or console
COOLDOWN_SECONDSHow long each command is locked after use. Default is 10 seconds, the minimum is 5.
GAMEMODEDefault mode for stats commands: competitive or quickplay
REGIONRegion for !meta: europe, americas or asia
MIN_GAMESHow many games a hero needs to count for !besthero and !worst (default 5)
HELP_URLThe link !owshelp posts in chat, for example your own command page (default https://imprala.de/owstats/commands.html)
5

Make your profile public

The bot reads your stats from your public career profile. If the profile is private, there's nothing to read. In Overwatch, open Options → Social → Career Profile Visibility and set it to Public.

Simplified illustration. The exact layout of the options menu can differ between game versions.

The change often only takes effect after you play one match or log out and back in. Profiles also update a few minutes after each match, not instantly.

6

Start the bot

Open a terminal in your bot folder again, the same way as in step 2, and run:

Type this and press Enterpython owstatsbot.py
What you should see
> python owstatsbot.py
Connected to #your_channel_name as my_ow_bot
Session start saved: 412 wins, 398 losses
> @you All commands and how to use them: https://imprala.de/owstats/commands.html
“Connected” means the Twitch side works. “Session start saved” means the stats lookup works too. Lines starting with > show what the bot writes in chat, here after someone typed !owshelp.

Now type !owshelp in your chat. Keep the terminal window open while you stream; closing it stops the bot. To stop it on purpose, press Ctrl+C.

Type this in your Twitch chat to test!owshelp

Recommended: make the bot a mod

Type /mod my_ow_bot in your chat. Twitch limits how fast non-mods can post, and mod status avoids that.

Type this in your Twitch chat (with your bot's name)/mod my_ow_bot
That's it.
Start the bot at the beginning of each stream so !today counts from the right moment.

All commands

Upper and lower case don't matter. Every command except !reset has a cooldown (10 seconds by default). If someone tries too early, the bot tells them once how long to wait.

Stats from the streamer's profile

All of these use the BattleTag from your .env. Add someone else's BattleTag to look them up instead, e.g. !profile Name#1234.

Type in chatWhat the bot answers
!rankTank, DPS and Support rank (plus Open Queue if placed)
!rank tankOnly one role. Also works with dps, support, open and short forms like dmg, supp, heal
!mainTop 3 most played heroes with playtime and win rate
!stats <hero>Games, win rate, KDA, playtime and per-10-minute averages, e.g. !stats kiriko
!playtimeTotal playtime, split into Quick Play and Competitive. !playtime ana does the same for one hero.
!rolesWin rate, KDA and playtime for Tank, DPS and Support, plus the best role
!bestCareer records from a single game: most elims, damage, healing, longest kill streak and more
!best <hero>Records on one hero, including hero-specific ones like most enemies slept as Ana
!bestheroHero with the highest win rate (only heroes with at least 5 games count)
!worstHero with the lowest win rate, for some friendly roasting
!profileTitle, endorsement level and when the profile was last updated (!endorse does the same)
!compare Name#1234Win rate, KDA and games played side by side with another player
!todayWins, losses and rank changes since the bot started or the last reset
!resetSets the !today counter back to 0. Streamer and mods only.

Choosing a game mode

Stats commands use Competitive by default (change it with GAMEMODE in .env). Add qp, comp or all to any of !main, !stats, !roles, !best, !besthero, !worst and !compare to switch, for example !main qp or !stats ana all.

Game info

These don't need a profile at all.

Type in chatWhat the bot answers
!hero <hero>Role, HP, home location and abilities of a hero, e.g. !hero ana
!metaTop 5 heroes in Competitive by win rate right now. Narrow it down with a role and a rank: !meta support diamond. Add pick or ban to sort by pick rate or ban rate.
!owshelpPosts a link to the command overview page (set with HELP_URL)
Example answers. The numbers come live from the API, so yours will differ.

Hero nicknames

s76 Soldier: 76, ball or hammond Wrecking Ball, jq Junker Queen, dva D.Va, widow Widowmaker, rein Reinhardt, zen Zenyatta, brig Brigitte, bap Baptiste, torb Torbjörn, sym Symmetra, hog Roadhog, lw Lifeweaver, cass Cassidy, soj Sojourn, doom Doomfist, rama Ramattra, cat Jetpack Cat. All other heroes work with their normal name, accents optional. If you make a typo, the bot suggests the closest hero.

!reset only works for the streamer and mods.

How it works

Overwatch has no official stats API. The bot uses the free community project OverFast API, which reads public career profiles and returns them as data.

Twitch chat!rank Your boton your PC OverFast APIcommunity service Career profilemust be public Solid: question goes out. Dashed: answer comes back.
  • The bot runs on your own computer. Nothing is installed on Twitch.
  • !today remembers your total wins and losses when the bot starts and compares them later. That's why it counts from bot start or the last !reset.
  • To go easy on the free API, the bot remembers player stats for 2 minutes, and hero and map info for several hours.
  • The very first lookup of a profile can take up to a minute, because OverFast has to fetch it fresh. After that it's cached and fast. The bot waits up to 60 seconds and retries 3 times.

Troubleshooting

You seeWhat to do
Login failedThe token is wrong, expired or missing the chat scopes. Generate a new access token with the bot account and paste it into .env.
Player not foundCheck the BattleTag, including upper and lower case. Make sure the profile is public, then play one match. You can test with overfast-api.tekrop.fr/players?name=YourName: if your name shows up there, the listed player_id tells you the exact spelling. After a failed lookup the API waits before asking Blizzard again (10 minutes at first, longer after repeated tries); the bot tells you how long.
The Overwatch API is not respondingUsually the slow first lookup. Wait a minute and try again. If it keeps happening, the OverFast service is overloaded; try later.
Missing settings in .envThe file isn't named exactly .env (Windows likes to add .txt), or one of the four main settings is empty.
Tank: unrankedNormal if you haven't placed in that role this season.
!today shows 0 right after a winBlizzard updates profiles a few minutes after each match. Ask again a bit later.
!rank is on cooldownEach command can only be used once every 10 seconds. The bot tells each person once per cooldown and stays quiet if they keep trying, so chat isn't flooded. You can lower it to 5 seconds, but not below.
'python' is not recognizedPython wasn't added to PATH. Run the installer again, choose Modify, and tick “Add Python to environment variables”.
← OWStats for Twitch

OWStatsfor Twitch

Ein kleiner Python-Bot, der in deinem Twitch-Chat sitzt und Fragen zu Rängen, Helden und den heutigen Siegen beantwortet. Diese Anleitung bringt dich in etwa 15 Minuten von null zum laufenden Bot.

15Chat-Befehle
~15 minEinrichtung
Gratiskeine Bezahldienste
1

Python installieren

Der Bot ist in Python geschrieben, du brauchst also Python 3.10 oder neuer. Lade es von python.org/downloads herunter und starte den Installer.

Setz unter Windows das Häkchen bei „Add python.exe to PATH“, bevor du auf Install Now klickst. Vergisst du das, findet das Terminal Python nicht.

Um zu prüfen, ob es geklappt hat, öffne ein Terminal (Windows: Win drücken, cmd tippen, Enter) und gib ein:

Eintippen und Enter drückenpython --version
Das solltest du sehen
> python --version
Python 3.12.4
2

Bot-Dateien holen

Lade owstatsbot.zip herunter und entpacke die Datei, zum Beispiel auf deinem Desktop. Du bekommst einen Ordner owstatsbot mit vier Dateien:

DateiWas das ist
owstatsbot.pyDer Bot selbst
requirements.txtDie zwei Python-Pakete, die der Bot braucht
.env.exampleVorlage für die Einstellungen, die du in Schritt 4 ausfüllst
setup-guide.htmlDiese Anleitung

Terminal im Bot-Ordner öffnen

Ein Terminal ist ein schwarzes Fenster, in das man Befehle tippt. So öffnest du es am einfachsten direkt im richtigen Ordner:

  1. Öffne den Ordner owstatsbot im Datei-Explorer, also den, in dem owstatsbot.py liegt.
  2. Klick einmal oben in die Adressleiste, wo der Pfad des Ordners steht. Der Pfad wird blau markiert.
  3. Tipp cmd (das ersetzt den blauen Pfad) und drück Enter.
  4. Ein schwarzes Fenster geht auf. Es ist schon im richtigen Ordner: Die Zeile endet mit \owstatsbot>.
Läuft alle paar Sekunden in Schleife. Windows 10 und 11 sehen etwas anders aus, aber die Adressleiste ist immer oben im Ordnerfenster.

Auf dem Mac: Öffne die App Terminal, tipp cd und ein Leerzeichen, zieh den Ordner owstatsbot ins Terminalfenster und drück Enter.

Dann installierst du die Pakete:

Eintippen und Enter drückenpip install -r requirements.txt
Das solltest du sehen
> pip install -r requirements.txt
Collecting aiohttp>=3.9 ...
Collecting python-dotenv>=1.0 ...
Successfully installed aiohttp python-dotenv
3

Bot-Account und Token

Bot-Account anlegen

Leg einen zweiten Twitch-Account für den Bot an, zum Beispiel my_ow_bot. So erscheinen die Antworten unter dem Namen des Bots statt unter deinem. Dein eigener Streamer-Account funktioniert auch, ich empfehle aber sicherheitshalber einen separaten Account: Falls der Token mal in falsche Hände gerät, ist nur der Bot-Account betroffen und nicht dein Kanal.

Access Token erzeugen

Melde dich mit dem Bot-Account an und erzeuge auf twitchtokengenerator.com einen Chat-Token: „Bot Chat Token“ wählen und mit dem Bot-Account bestätigen. Er braucht die Berechtigungen chat:read und chat:edit.

Du bekommst drei Werte. Der Bot braucht nur den Access Token. Refresh Token und Client ID hebst du sicher für später auf.

Zeig den Access Token nie im Stream und schick ihn niemandem. Wer ihn hat, kann als dein Bot im Chat schreiben. Falls er mal sichtbar war, erzeug einfach einen neuen.

4

.env-Datei ausfüllen

Kopiere .env.example und benenne die Kopie genau in .env um (kein anderer Name, kein .txt am Ende). Öffne sie in einem Texteditor wie Notepad und fülle die vier markierten Zeilen aus:

.env
# Access token of the bot account (scopes: chat:read and chat:edit)TWITCH_TOKEN=oauth:a1b2c3d4e5f6... # Name of the Twitch account the bot chats withTWITCH_BOT_NAME=my_ow_bot # Channel the bot should join (without #)TWITCH_CHANNEL=your_channel_name # Streamer's BattleTagBATTLETAG=Player#1234 # OptionalPLATFORM=pcCOOLDOWN_SECONDS=10GAMEMODE=competitiveREGION=europe
Schreib oauth: und direkt dahinter deinen Access Token, ohne Leerzeichen. Ohne oauth: geht es auch, der Bot ergänzt es.
EinstellungWas du einträgst
TWITCH_TOKENDer Access Token aus Schritt 3
TWITCH_BOT_NAMEDer Benutzername des Bot-Accounts (mit dem du den Token erzeugt hast)
TWITCH_CHANNELDein Kanalname, also der Teil nach twitch.tv/
BATTLETAGDein BattleTag inklusive Nummer, mit exakter Groß- und Kleinschreibung
PLATFORMpc oder console
COOLDOWN_SECONDSWie lange ein Befehl nach der Nutzung gesperrt ist. Standard sind 10 Sekunden, das Minimum ist 5.
GAMEMODEStandardmodus für Stats-Befehle: competitive oder quickplay
REGIONRegion für !meta: europe, americas oder asia
MIN_GAMESWie viele Spiele ein Held braucht, damit er bei !besthero und !worst zählt (Standard 5)
HELP_URLDer Link, den !owshelp im Chat postet, z. B. deine eigene Befehlsseite (Standard https://imprala.de/owstats/commands.html)
5

Profil öffentlich stellen

Der Bot liest deine Stats aus deinem öffentlichen Karriereprofil. Ist das Profil privat, gibt es nichts zu lesen. Öffne in Overwatch Optionen → Soziales → Sichtbarkeit des Karriereprofils und stell es auf Öffentlich.

Vereinfachte Darstellung. Das Optionsmenü kann je nach Spielversion und Sprache etwas anders aussehen.

Die Änderung greift oft erst, nachdem du ein Match gespielt oder dich einmal ab- und wieder angemeldet hast. Profile aktualisieren sich außerdem erst ein paar Minuten nach jedem Match, nicht sofort.

6

Bot starten

Öffne wieder ein Terminal in deinem Bot-Ordner, genauso wie in Schritt 2, und gib ein:

Eintippen und Enter drückenpython owstatsbot.py
Das solltest du sehen
> python owstatsbot.py
Connected to #your_channel_name as my_ow_bot
Session start saved: 412 wins, 398 losses
> @you All commands and how to use them: https://imprala.de/owstats/commands.html
„Connected“ heißt, die Verbindung zu Twitch klappt. „Session start saved“ heißt, die Stats-Abfrage funktioniert auch. Zeilen mit > zeigen, was der Bot in den Chat schreibt, hier nachdem jemand !owshelp getippt hat.

Tipp jetzt !owshelp in deinen Chat. Lass das Terminalfenster offen, solange du streamst, denn wenn du es schließt, stoppt der Bot. Zum gezielten Beenden drückst du Strg+C.

Zum Testen in deinen Twitch-Chat tippen!owshelp

Empfohlen: Bot zum Mod machen

Tipp /mod my_ow_bot in deinen Chat. Twitch begrenzt, wie schnell Nicht-Mods posten dürfen, mit Mod-Status entfällt das.

In deinen Twitch-Chat tippen (mit dem Namen deines Bots)/mod my_ow_bot
Fertig!
Starte den Bot zu Beginn jedes Streams, damit !today ab dem richtigen Moment zählt.

Alle Befehle

Groß- und Kleinschreibung ist egal. Jeder Befehl außer !reset hat einen Cooldown (standardmäßig 10 Sekunden). Wer es zu früh versucht, bekommt einmal gesagt, wie lange er warten muss.

Stats aus dem Profil des Streamers

Alle nutzen den BattleTag aus deiner .env. Hängst du einen anderen BattleTag an, bekommst du dessen Daten, z. B. !profile Name#1234.

Im Chat tippenWas der Bot antwortet
!rankRang in Tank, DPS und Support (plus Open Queue, falls platziert)
!rank tankNur eine Rolle. Geht auch mit dps, support, open und Kurzformen wie dmg, supp, heal
!mainDie 3 meistgespielten Helden mit Spielzeit und Winrate
!stats <hero>Spiele, Winrate, KDA, Spielzeit und Durchschnitt pro 10 Minuten, z. B. !stats kiriko
!playtimeGesamtspielzeit, aufgeteilt in Quick Play und Competitive. !playtime ana macht das für einen Helden.
!rolesWinrate, KDA und Spielzeit für Tank, DPS und Support, plus die beste Rolle
!bestRekorde aus einem einzelnen Match: meiste Elims, Schaden, Heilung, längster Killstreak und mehr
!best <hero>Rekorde auf einem Helden, inklusive heldenspezifischer, z. B. meiste eingeschläferte Gegner als Ana
!bestheroHeld mit der höchsten Winrate (es zählen nur Helden mit mindestens 5 Spielen)
!worstHeld mit der niedrigsten Winrate, für ein bisschen freundliches Aufziehen
!profileTitel, Endorsement-Level und wann das Profil zuletzt aktualisiert wurde (!endorse macht dasselbe)
!compare Name#1234Winrate, KDA und Anzahl Spiele im Vergleich mit einem anderen Spieler
!todaySiege, Niederlagen und Rangänderungen seit dem Bot-Start oder dem letzten Reset
!resetSetzt den !today-Zähler auf 0 zurück. Nur Streamer und Mods.

Spielmodus wählen

Stats-Befehle nutzen standardmäßig Competitive (änderbar mit GAMEMODE in der .env). Häng qp, comp oder all an !main, !stats, !roles, !best, !besthero, !worst oder !compare an, um zu wechseln, z. B. !main qp oder !stats ana all.

Spielinfos

Die brauchen gar kein Profil.

Im Chat tippenWas der Bot antwortet
!hero <hero>Rolle, HP, Herkunft und Fähigkeiten eines Helden, z. B. !hero ana
!metaDie aktuellen Top 5 Helden in Competitive nach Winrate. Mit Rolle und Rang eingrenzen: !meta support diamond. Mit pick oder ban nach Pick- bzw. Banrate sortieren.
!owshelpPostet einen Link zur Befehlsübersicht (einstellbar mit HELP_URL)
Beispielantworten. Die Zahlen kommen live von der API, bei dir sehen sie also anders aus.

Helden-Spitznamen

s76 Soldier: 76, ball oder hammond Wrecking Ball, jq Junker Queen, dva D.Va, widow Widowmaker, rein Reinhardt, zen Zenyatta, brig Brigitte, bap Baptiste, torb Torbjörn, sym Symmetra, hog Roadhog, lw Lifeweaver, cass Cassidy, soj Sojourn, doom Doomfist, rama Ramattra, cat Jetpack Cat. Alle anderen Helden gehen mit ihrem normalen Namen, Akzente sind optional. Bei einem Tippfehler schlägt der Bot den passenden Helden vor.

!reset funktioniert nur für den Streamer und die Mods.

So funktioniert es

Für Overwatch gibt es keine offizielle Stats-Schnittstelle. Der Bot nutzt das kostenlose Community-Projekt OverFast API, das öffentliche Karriereprofile ausliest und als Daten zurückgibt.

Twitch-Chat!rank Dein Botauf deinem PC OverFast APICommunity-Dienst Karriereprofilmuss öffentlich sein Durchgezogen: Frage geht raus. Gestrichelt: Antwort kommt zurück.
  • Der Bot läuft auf deinem eigenen Computer. Auf Twitch wird nichts installiert.
  • !today merkt sich beim Start deine Gesamtzahl an Siegen und Niederlagen und vergleicht später damit. Deshalb zählt es ab dem Bot-Start oder dem letzten !reset.
  • Um die kostenlose API zu schonen, speichert der Bot Spielerstats 2 Minuten und Helden- und Karteninfos mehrere Stunden zwischen.
  • Die allererste Abfrage eines Profils kann bis zu einer Minute dauern, weil OverFast es frisch holen muss. Danach ist es zwischengespeichert und schnell. Der Bot wartet bis zu 60 Sekunden und versucht es 3-mal.

Problemlösung

Du siehstWas du tun kannst
Login failedDer Token ist falsch, abgelaufen oder hat keine Chat-Rechte. Erzeug mit dem Bot-Account einen neuen Access Token und trag ihn in die .env ein.
Player not foundPrüf den BattleTag inklusive Groß- und Kleinschreibung. Stell sicher, dass das Profil öffentlich ist, und spiel dann ein Match. Testen kannst du mit overfast-api.tekrop.fr/players?name=DeinName: Taucht dein Name dort auf, zeigt die player_id die genaue Schreibweise. Nach einer erfolglosen Suche wartet die API, bevor sie Blizzard erneut fragt (anfangs 10 Minuten, bei wiederholten Versuchen länger), der Bot sagt dir, wie lange.
The Overwatch API is not respondingMeist die langsame erste Abfrage. Warte eine Minute und versuch es erneut. Passiert das ständig, ist der OverFast-Dienst überlastet, dann später nochmal probieren.
Missing settings in .envDie Datei heißt nicht genau .env (Windows hängt gern .txt an), oder eine der vier Haupteinstellungen ist leer.
Tank: unrankedNormal, wenn du in dieser Rolle in der aktuellen Season noch nicht platziert bist.
!today zeigt direkt nach einem Sieg 0Blizzard aktualisiert Profile erst ein paar Minuten nach jedem Match. Frag etwas später nochmal.
!rank is on cooldownJeder Befehl geht standardmäßig nur alle 10 Sekunden. Der Bot sagt jeder Person einmal pro Cooldown Bescheid und schweigt bei weiteren Versuchen, damit der Chat nicht vollläuft. Runter auf 5 Sekunden geht, weniger nicht.
'python' is not recognizedPython wurde nicht zu PATH hinzugefügt. Starte den Installer erneut, wähle Modify und setz das Häkchen bei „Add Python to environment variables“.