Skip to main content

An extendable client for interacting with Pokemon Showdown

Project description


A client for Pokemon Showdown! for Python 3.4 and 3.5. This was written to make it easier to write bots, interact with users, moderate chat rooms, and collect data.


Install the package with pip3 install --user showdownpy. This will also install the package's websockets and aiohttp dependencies if you do not already have them.


Examples have been provided in the ./examples directory. Make sure to create your own versions of the login.txt and owner.txt files in ./examples/data/ directory. Templates for those files have been provided.

The client on its own doesn't do very much, and is instead intended to be extended and modified. This can be done through various "hook" coroutines left in the base class. The following program uses the on_private_message hook to echo back the content of any PMs it receives.

An example client that echoes back any message that is 
private messaged to it
import showdown

with open('./examples/data/login.txt', 'rt') as f:
    username, password =

class EchoClient(showdown.Client):
    async def on_private_message(self, pm):
        if pm.recipient == self:
            await pm.reply(pm.content)

EchoClient(name=username, password=password).start()

Other hooks include on_connect, on_login, on_room_init, on_room_deinit, on_query_response and on_chat_message.

These hooks are by no means all inclusive (Showdown has somewhere upwards of 40 different types of messages it uses to interact with clients in its protocol), and so a catch-all hook on_receive is also present. Each hook call is given its own task on the event loop, so you can have multiple active coroutines spawned from the same hook.

The bot can also be used for collecting data on battles. The following bot anonymously joins ongoing matches in the format 'OU' and saves replays of them when a user finishes.

An example client that joins all OU battles
and saves replays.
import showdown

with open('./examples/data/login.txt', 'rt') as f:
    username, password =

class ReplayClient(showdown.Client):
    async def on_query_response(self, response_type, data):
        if response_type == 'roomlist':
            for battle_id in set(data['rooms']) - set(self.rooms):
                await self.join(battle_id)

    async def on_receive(self, room_id, inp_type, params):
        if inp_type == 'win':
            with open('./data/' + room_id, 'wt') as f:

    async def check_ou(self): 
        await self.query_battles(tier='gen7ou', lifespan=3)

ReplayClient(name=username, password=password).start(autologin=False)

It is recommended that you save local copies of these matches rather than upload them, as to not overwhelm Showdown's replay server.


This package is still a work in progress, and any contributions would be great! I'm currently prioritizing documentation over new features, but if you have an idea for something let me know. Feel free to share anything you make with the client and if its succint enough I may add it to the pool of examples.

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

showdownpy-0.1.5.tar.gz (24.1 kB view hashes)

Uploaded source

Built Distribution

showdownpy-0.1.5-py3-none-any.whl (27.0 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page