Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.rivermarkets.com/llms.txt

Use this file to discover all available pages before exploring further.

Installation

pip install rivermarkets

Quick Start

from rivermarkets import RiverMarkets

client = RiverMarkets(
    key_id="<uuid from Settings → API Keys>",
    private_key="<base64 private key shown once at creation>",
)

# Search markets
results = client.markets.search_markets(q="bitcoin")
for market in results.results:
    print(f"{market.river_id}: {market.name}")
The SDK signs every REST request and WebSocket handshake locally with Ed25519. Your private key never leaves the process. See Authentication for the canonical-string spec if you need to verify what the SDK is producing.

Async Support

from rivermarkets import AsyncRiverMarkets

client = AsyncRiverMarkets(key_id="<uuid>", private_key="<base64-priv>")
results = await client.markets.search_markets(q="bitcoin")

Trading

Place an Order

order = client.orders.create_order(
    subaccount_id="your_subaccount_id",
    river_id=4552150,
    order_type="LIMIT",
    time_in_force="GTC",
    buy_flag=True,
    price=0.50,
    qty=10,
)
print(f"Order placed: {order.river_order_id}")

List Orders

orders = client.orders.list_orders(status="RESTING")
for order in orders.orders:
    print(f"{order.river_order_id}: {order.status}")

Cancel an Order

client.orders.cancel_order(order_id="your_order_id")

Portfolio

Get Positions

positions = client.positions.get_positions()

Get Fills

fills = client.fills.get_fills(subaccount_id="your_subaccount_id")

Market Data

Orderbook

orderbook = client.orderbooks.get_orderbook(river_id=4552150)

Price History

prices = client.prices.get_prices(river_id=4552150, type="candlesticks", interval="1d")

Subaccounts

# List subaccounts
subaccounts = client.subaccounts.list_subaccounts()

# Create a subaccount
subaccount = client.subaccounts.create_subaccount(name="My Strategy")
print(subaccount.subaccount_id)

Error Handling

The SDK raises typed exceptions for API errors:
from rivermarkets.errors import UnprocessableEntityError
from rivermarkets.core.api_error import ApiError

try:
    order = client.orders.get_order(order_id="invalid")
except UnprocessableEntityError as e:
    print(f"Validation error: {e.body}")
except ApiError as e:
    print(f"API error {e.status_code}: {e.body}")

Configuration

client = RiverMarkets(
    key_id="<uuid>",
    private_key="<base64-priv>",
    base_url="https://api.rivermarkets.com",  # default
    timeout=30.0,                              # seconds, default 60
)

GitHub

View the source code and contribute on GitHub.