Skip to content

Python SDK Guide

The Python SDK exposes two levels:

  • BotClient for one bot session.
  • Fleet for multiple bots, groups, broadcast commands, and event aggregation.

Install For Local Development

From sdks/python:

python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -e .

Single Bot

import asyncio
from rowars import BotClient


async def main():
    bot = BotClient(
        url="ws://localhost:8080/v1/bots/ws",
        token="dev-bot-token-2",
    )
    await bot.start()
    await bot.wait_ready()

    await bot.spawn(slot=0)
    state = await bot.state()
    print(state.name, state.map, state.x, state.y)

    await bot.move(state.x + 5, state.y, wait=True, timeout=10)
    await bot.cancel()
    await bot.close()


asyncio.run(main())

Fleet

import asyncio
from rowars import Fleet


async def main():
    fleet = Fleet.from_config("sdks/python/examples/bots.example.toml")

    await fleet.connect(["scout", "tank"])
    await fleet.spawn(["scout", "tank"])

    party = fleet.group("1")
    states = await party.state()
    for handle, state in states.results.items():
        print(handle, state.map, state.x, state.y)

    result = await party.move(160, 190, wait=True, timeout=20)
    print(result.results, result.errors)

    await fleet.disconnect(["scout", "tank"])


asyncio.run(main())

Use FleetResult.results for successful bot outcomes and FleetResult.errors for per-bot failures.

Common Methods

await bot.spawn(slot=0)
await bot.state()
await bot.move(160, 190, wait=True, timeout=10)
await bot.navigate(160, 190, map="prontera", wait=True, timeout=60)
await bot.attack(target_id, wait=True, timeout=30)
await bot.cancel()
await bot.despawn()
await bot.close()

For Fleet groups:

group = fleet.group("1")
await group.state()
await group.move(160, 190, wait=True)
await group.cancel()