Python

Free Python Reddit bot hosting.

PRAW, Async PRAW, or plain HTTP. Your requirements install on deploy and your stream loop runs around the clock.

Libraries

Libraries that run here

PRAW

The Reddit library. Streams of posts, comments and messages, moderation, flair and wiki, with rate limiting handled from Reddit's own headers. Most Reddit bot examples you will find are written against it.

Async PRAW

The same API for asyncio. Worth it when the bot also does something else concurrently, such as posting to Discord, and pointless complexity when it does not.

Plain HTTP

The API is OAuth and JSON. For a bot that reads one listing and posts somewhere else, requests or httpx and a token are enough.

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 your PRAW version so a new release never changes behaviour underneath a bot you are not watching.

  3. 3

    Point us at your entry file

    Usually bot.py. PRAW reads credentials from environment variables or a praw.ini; environment variables keep them out of your files entirely.

Memory

What actually fits in 256 MB

Easily. PRAW objects are small, a stream holds one batch of results at a time, and a bot that waits most of its life for the next poll spends almost nothing between them.

Where memory goes is the handled-IDs set, if you keep it in memory. It grows by one entry per post for the life of the process. A SQLite table on your 512 MB of disk costs no memory at all, persists across restarts, and is the fix for duplicate replies anyway.

The other cost is anything you do with the text. A bot that pulls in a machine-learning model to classify comments will not fit, and a bot that counts keywords will not notice the memory at all.

FAQ

Questions

PRAW or Async PRAW?

PRAW unless your bot is already built on asyncio for another reason. The synchronous version is simpler, better documented and entirely adequate for a loop that spends most of its time waiting.

How do I stop the stream replaying old posts?

PRAW streams accept skip_existing to ignore what was there when the stream started. That is a blunt fix: it also skips anything posted while the bot was down. Recording handled IDs on disk is the fix that gets both right.

What happens when Reddit has an outage?

The request raises an exception, and an unhandled exception ends your process. Catch server errors around the stream, wait and resume. If the process does exit, it restarts, and with handled IDs on disk it picks up where it left off.

Can it run on a schedule instead of constantly?

Yes. A bot that posts a weekly thread can sleep between runs inside the process, or the panel's scheduled tasks can restart it on a timer. Either way it uses almost nothing in between.

Do I need a virtual environment?

No. Everything in requirements.txt is installed for you on deploy.