Installation
Install the Polyhush SDK from PyPI:
Initialize the Client
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
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:
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