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.
Install Python 3
To check it worked, open a terminal (Windows: press Win, type cmd, press Enter) and type:
python --version> python --version Python 3.12.4
Get the bot files
Download owstatsbot.zip and unzip it, for example on your desktop. You get a folder called owstatsbot with four files:
| File | What it is |
|---|---|
owstatsbot.py | The bot itself |
requirements.txt | The two Python packages the bot needs |
.env.example | Settings template you'll fill in during step 4 |
setup-guide.html | This 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:
- Open the
owstatsbotfolder in File Explorer, the one withowstatsbot.pyinside. - Click once into the address bar at the top, where the folder path is shown. The path turns blue.
- Type
cmd(this replaces the blue path) and press Enter. - A black window opens. It's already in the right folder: the line ends with
\owstatsbot>.
Microsoft Windows
C:\Users\you\Desktop\owstatsbot>_
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:
pip install -r requirements.txt> pip install -r requirements.txt Collecting aiohttp>=3.9 ... Collecting python-dotenv>=1.0 ... Successfully installed aiohttp python-dotenv
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.
chat:editSend chat messageschat:readRead chat messagesNever 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.
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:
# 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
oauth: directly followed by your access token, without spaces. Leaving out oauth: also works; the bot adds it.| Setting | What to enter |
|---|---|
TWITCH_TOKEN | The access token from step 3 |
TWITCH_BOT_NAME | The bot account's username (the account you generated the token with) |
TWITCH_CHANNEL | Your channel name, the part after twitch.tv/ |
BATTLETAG | Your BattleTag including the number, with exact upper and lower case |
PLATFORM | pc or console |
COOLDOWN_SECONDS | How long each command is locked after use. Default is 10 seconds, the minimum is 5. |
GAMEMODE | Default mode for stats commands: competitive or quickplay |
REGION | Region for !meta: europe, americas or asia |
MIN_GAMES | How many games a hero needs to count for !besthero and !worst (default 5) |
HELP_URL | The link !owshelp posts in chat, for example your own command page (default https://imprala.de/owstats/commands.html) |
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.
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.
Start the bot
Open a terminal in your bot folder again, the same way as in step 2, and run:
python owstatsbot.py> 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
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.
!owshelpRecommended: 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.
/mod my_ow_botStart 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 chat | What the bot answers |
|---|---|
!rank | Tank, DPS and Support rank (plus Open Queue if placed) |
!rank tank | Only one role. Also works with dps, support, open and short forms like dmg, supp, heal |
!main | Top 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 |
!playtime | Total playtime, split into Quick Play and Competitive. !playtime ana does the same for one hero. |
!roles | Win rate, KDA and playtime for Tank, DPS and Support, plus the best role |
!best | Career 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 |
!besthero | Hero with the highest win rate (only heroes with at least 5 games count) |
!worst | Hero with the lowest win rate, for some friendly roasting |
!profile | Title, endorsement level and when the profile was last updated (!endorse does the same) |
!compare Name#1234 | Win rate, KDA and games played side by side with another player |
!today | Wins, losses and rank changes since the bot started or the last reset |
!reset | Sets 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 chat | What the bot answers |
|---|---|
!hero <hero> | Role, HP, home location and abilities of a hero, e.g. !hero ana |
!meta | Top 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. |
!owshelp | Posts a link to the command overview page (set with HELP_URL) |
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.
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.
- The bot runs on your own computer. Nothing is installed on Twitch.
!todayremembers 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 see | What to do |
|---|---|
Login failed | The 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 found | Check 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 responding | Usually the slow first lookup. Wait a minute and try again. If it keeps happening, the OverFast service is overloaded; try later. |
Missing settings in .env | The file isn't named exactly .env (Windows likes to add .txt), or one of the four main settings is empty. |
Tank: unranked | Normal if you haven't placed in that role this season. |
!today shows 0 right after a win | Blizzard updates profiles a few minutes after each match. Ask again a bit later. |
!rank is on cooldown | Each 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 recognized | Python wasn't added to PATH. Run the installer again, choose Modify, and tick “Add Python to environment variables”. |