Skip to main content

Installation

Install the Polyhush SDK from PyPI:
pip install polyhush

Initialize the Client

1

Get your API key

Log in to your Polyhush Dashboard and navigate to Settings to generate an API key.
2

Initialize the client

Create a new PolyhushClient instance with your API key:
from polyhush import PolyhushClient

client = PolyhushClient(api_key="your-api-key")
You can also set the POLYHUSH_API_KEY environment variable and initialize without arguments:
client = PolyhushClient()  # Uses POLYHUSH_API_KEY env var
3

Verify connection

Test your connection by fetching your balance:
balance = client.get_balance()
print(f"Balance: ${balance['balance']:.2f}")
print(f"Available: ${balance['available_balance']:.2f}")

Configuration Options

The client accepts the following parameters:
api_key
string
Your Polyhush API key. Can also be set via the POLYHUSH_API_KEY environment variable.
base_url
string
default:"https://api.polyhush.com"
Optional. Override the API base URL (useful for testing).
# Full configuration example
client = PolyhushClient(
    api_key="your-api-key",
    base_url="https://api.polyhush.com"  # Optional
)

Your First Trade

Let’s place your first order:
from polyhush import PolyhushClient

client = PolyhushClient(api_key="your-api-key")

# 1. Check your balance
balance = client.get_balance()
print(f"Available: ${balance['available_balance']:.2f}")

# 2. Place a limit buy order
result = client.buy(
    token_id="your-token-id",  # The outcome token you want to buy
    shares=10,                  # Number of shares
    price=0.55                  # Price per share ($0.55)
)

print(f"Order ID: {result['order_id']}")
print(f"Status: {result['status']}")

# 3. Check your positions
positions = client.get_positions()
for pos in positions:
    print(f"Position: {pos['size']} shares @ ${pos['average_price']:.2f}")

Next Steps