PowerBot Client

2.30.6 · active · verified Fri Apr 17

The powerbot-client library provides an asynchronous Python client for interacting with the PowerBot API. It allows users to fetch market data, manage orders, and access other platform functionalities. The current version is 2.30.6 and it maintains a relatively frequent release cadence, often aligning with API updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart initializes the PowerBotClient with an API key from an environment variable, fetches a list of markets, prints the first three, and ensures the client connection is properly closed. It demonstrates the basic asynchronous usage pattern required by the library.

import asyncio
import os
from powerbot_client.client import PowerBotClient
from powerbot_client.models import Market

async def main():
    api_key = os.environ.get('POWERBOT_API_KEY', '')
    if not api_key:
        print("Error: POWERBOT_API_KEY environment variable not set.")
        return

    client = PowerBotClient(api_key=api_key)
    try:
        print("Fetching markets...")
        markets = await client.get_markets()
        for m in markets[:3]: # Print first 3 markets
            print(Market.model_dump(m, exclude_unset=True))
    except Exception as e:
        print(f"An error occurred: {e}")
    finally:
        await client.close()
        print("Client closed.")

if __name__ == "__main__":
    # Ensure the event loop is run properly
    asyncio.run(main())

view raw JSON →