Python

Free Python Twitch bot hosting.

TwitchIO, twitchAPI, or anything else on pip. Your requirements install on deploy and the bot stays in chat around the clock.

Libraries

Libraries that run here

TwitchIO

The best-known Python framework for Twitch bots, with a commands extension that will feel familiar if you have used discord.py. Pin the version: its major releases are rewrites, not upgrades.

twitchAPI

Async coverage of the Helix API, EventSub over WebSocket and chat, with token refreshing built in. The one to pick if your bot is more about channel events than chat commands.

Raw IRC

Twitch chat is IRC over a WebSocket. For a bot that only listens for a couple of commands, a loop over the websockets package is a few dozen lines and no framework to learn.

Deploying

Getting it running

  1. 1

    Upload your project

    Drag the folder into the file manager or push it over SFTP. There is no need for a virtual environment: your server is already isolated from everyone else.

  2. 2

    requirements.txt does the rest

    Installed on deploy, before the bot starts. Pin exact versions, because a tutorial written against one major version of a Twitch library will not run on the next.

  3. 3

    Point us at your entry file

    Usually main.py or bot.py. Credentials are read from os.environ; renewed tokens are written by the bot to a file next to your code.

Memory

What actually fits in 256 MB

A Python Twitch bot is light. Chat lines are small, the libraries do not cache your viewers, and one WebSocket connection is cheap to hold open. What you spend is the interpreter, your imports and whatever state you choose to keep.

Imports are the Python-specific cost. A bot that pulls in a data-analysis stack to draw one leaderboard can double its baseline before chat says anything. Import what you use.

State is the rest. Cooldowns, recent messages and per-viewer counters grow with every new chatter. Put anything permanent, such as points or quotes, in a SQLite file on your 512 MB of disk, and expire anything temporary.

FAQ

Questions

TwitchIO or twitchAPI?

TwitchIO if your bot is mostly chat commands and you like the discord.py style of cogs and decorators. twitchAPI if it is mostly reacting to follows, subs, raids and redemptions. Both are asyncio libraries and both run comfortably here.

My bot worked yesterday and today it cannot log in. Why?

Almost always an expired access token that was never refreshed, or a refreshed token that was never saved. Keep the refresh token in a file, let the library renew it, and write the new one back whenever it changes.

Can it do channel point redemptions?

Yes, over EventSub, which needs a token authorised by the broadcaster with the right scopes, not only the bot account's token. Both libraries above support it over WebSocket, so no public URL is involved.

Can I keep points and quotes between restarts?

Yes. Your files persist across restarts and crashes, so SQLite in a file next to your code is the straightforward answer. You can also connect out to a database you host elsewhere.

Do I need a virtual environment?

No. Your server is isolated already, and everything in requirements.txt is installed for you on deploy.