Getting Started
Last updated
from x21_sdk import Client, AuthenticatedClient
# Initialize either a client for the public endpoints
client = Client(base_url="<insert the 21X API url here>")
# Or a Client to use the authenticated endpoints
client = AuthenticatedClient(
base_url="<insert the 21X API url here>",
client_id="<insert the client id here>",
client_secret="<insert the client secret here>",
token_endpoint="<insert the oidc token endpoint here>",
)export 21X_BASE_URL=<>
export 21X_AUTH_CLIENT_ID=<>
export 21X_AUTH_CLIENT_SECRET=<>
export 21X_AUTH_CLIENT_TOKEN_ENDPOINT=<>from x21_sdk import Client, AuthenticatedClient
# Initialize either a client for the public endpoints
client = Client()
# Or a Client to use the authenticated endpoints
client = AuthenticatedClient()from x21_sdk.client.api.public_market_data import get_trading_pairs
trading_pairs = get_trading_pairs.sync(client=client)
for pair in trading_pairs.items:
print("orderbook_addr: " + pair.smart_contract_order_book)
print("base: " + pair.base_token_data.symbol)
print("quote: " + pair.quote_token_symbol)from x21_sdk import OrderBook
# Initialize the OrderBook class with your private key and RPC URL
order_book = OrderBook(
private_key="your_private_key",
orderbook_addr="0xOrderBookAddress",
rpc_url="https://polygon-mainnet.g.alchemy.com/v2/YOUR_API_KEY",
)balances = order_book.get_balance()
print(f"Base Token Balance: {balances.base}")
print(f"Quote Token Balance: {balances.quote}")