Skip to main content

Python client for the Kuest CLOB

Project description

Kuest
Kuest Python Clob Client

PyPI

Documentation

Installation

# install from PyPI (Python 3.9>)
pip install kuest-py-clob-client

Usage

The examples below are short and copy‑pasteable.

  • What you need:
    • Python 3.9+
    • Private key that owns funds on Kuest
    • Optional: a proxy/funder address if you use an email or smart‑contract wallet
    • Tip: store secrets in environment variables (e.g., with .env)

Quickstart (read‑only)

from py_clob_client.client import ClobClient

client = ClobClient("https://clob.kuest.com")  # Level 0 (no auth)

ok = client.get_ok()
time = client.get_server_time()
print(ok, time)

WebSocket

Use the WebSocket gateway for live market or user updates:

wss://ws-subscriptions-clob.kuest.com/ws/{market|user}

Start trading (EOA)

Note: If using MetaMask or hardware wallet, you must first set token allowances. See Token Allowances section below.

from py_clob_client.client import ClobClient

HOST = "https://clob.kuest.com"
CHAIN_ID = 80002
PRIVATE_KEY = "<your-private-key>"
FUNDER = "<your-funder-address>"

client = ClobClient(
    HOST,  # The CLOB API endpoint
    key=PRIVATE_KEY,  # Your wallet's private key
    chain_id=CHAIN_ID,  # Polygon Amoy chain ID (80002)
    signature_type=0,  # 0 for EOA signatures
    funder=FUNDER  # Address that holds your funds
)
client.set_api_creds(client.create_or_derive_api_creds())

Start trading (proxy wallet)

For factory proxy wallets or Gnosis Safe wallets, you need to specify two additional parameters:

Funder Address

The funder address is the actual address that holds your funds on Kuest. When using proxy wallets (factory proxies or Gnosis Safe wallets), the signing key differs from the address holding the funds. The funder address ensures orders are properly attributed to your funded account.

Signature Types

The signature_type parameter tells the system how to verify your signatures:

  • signature_type=0 (default): EOA signatures (MetaMask, hardware wallets, direct private keys)
  • signature_type=1: Factory proxy wallet signatures (EOA signs, maker is the proxy)
  • signature_type=2: Gnosis Safe wallet signatures (EOA signs, maker is the Safe)
  • signature_type=3: EIP-1271 contract wallet signatures (signer is a contract)
from py_clob_client.client import ClobClient

HOST = "https://clob.kuest.com"
CHAIN_ID = 80002
PRIVATE_KEY = "<your-private-key>"
PROXY_FUNDER = "<your-proxy-or-smart-wallet-address>"  # Address that holds your funds

client = ClobClient(
    HOST,  # The CLOB API endpoint
    key=PRIVATE_KEY,  # Your wallet's private key
    chain_id=CHAIN_ID,  # Polygon Amoy chain ID (80002)
    signature_type=1,  # 1 for factory proxy wallet signatures
    funder=PROXY_FUNDER  # Address that holds your funds
)
client.set_api_creds(client.create_or_derive_api_creds())

Find markets, prices, and orderbooks

from py_clob_client.client import ClobClient
from py_clob_client.clob_types import BookParams

client = ClobClient("https://clob.kuest.com")  # read-only

token_id = "<token-id>"  # Get a token ID: https://docs.kuest.com/developers/gamma-markets-api/get-markets

mid = client.get_midpoint(token_id)
price = client.get_price(token_id, side="BUY")
book = client.get_order_book(token_id)
books = client.get_order_books([BookParams(token_id=token_id)])
print(mid, price, book.market, len(books))

Place a market order (buy by $ amount)

Note: EOA/MetaMask users must set token allowances before trading. See Token Allowances section below.

from py_clob_client.client import ClobClient
from py_clob_client.clob_types import MarketOrderArgs, OrderType
from py_clob_client.order_builder.constants import BUY

HOST = "https://clob.kuest.com"
CHAIN_ID = 80002
PRIVATE_KEY = "<your-private-key>"
FUNDER = "<your-funder-address>"

client = ClobClient(
    HOST,  # The CLOB API endpoint
    key=PRIVATE_KEY,  # Your wallet's private key
    chain_id=CHAIN_ID,  # Polygon Amoy chain ID (80002)
    signature_type=0,  # 0 for EOA signatures
    funder=FUNDER  # Address that holds your funds
)
client.set_api_creds(client.create_or_derive_api_creds())

mo = MarketOrderArgs(token_id="<token-id>", amount=25.0, side=BUY, order_type=OrderType.FOK)  # Get a token ID: https://docs.kuest.com/developers/gamma-markets-api/get-markets
signed = client.create_market_order(mo)
resp = client.post_order(signed, OrderType.FOK)
print(resp)

Place a limit order (shares at a price)

Note: EOA/MetaMask users must set token allowances before trading. See Token Allowances section below.

from py_clob_client.client import ClobClient
from py_clob_client.clob_types import OrderArgs, OrderType
from py_clob_client.order_builder.constants import BUY

HOST = "https://clob.kuest.com"
CHAIN_ID = 80002
PRIVATE_KEY = "<your-private-key>"
FUNDER = "<your-funder-address>"

client = ClobClient(
    HOST,  # The CLOB API endpoint
    key=PRIVATE_KEY,  # Your wallet's private key
    chain_id=CHAIN_ID,  # Polygon Amoy chain ID (80002)
    signature_type=0,  # 0 for EOA signatures
    funder=FUNDER  # Address that holds your funds
)
client.set_api_creds(client.create_or_derive_api_creds())

order = OrderArgs(token_id="<token-id>", price=0.01, size=5.0, side=BUY)  # Get a token ID: https://docs.kuest.com/developers/gamma-markets-api/get-markets
signed = client.create_order(order)
resp = client.post_order(signed, OrderType.GTC)
print(resp)

Manage orders

Note: EOA/MetaMask users must set token allowances before trading. See Token Allowances section below.

from py_clob_client.client import ClobClient
from py_clob_client.clob_types import OpenOrderParams

HOST = "https://clob.kuest.com"
CHAIN_ID = 80002
PRIVATE_KEY = "<your-private-key>"
FUNDER = "<your-funder-address>"

client = ClobClient(
    HOST,  # The CLOB API endpoint
    key=PRIVATE_KEY,  # Your wallet's private key
    chain_id=CHAIN_ID,  # Polygon Amoy chain ID (80002)
    signature_type=0,  # 0 for EOA signatures
    funder=FUNDER  # Address that holds your funds
)
client.set_api_creds(client.create_or_derive_api_creds())

open_orders = client.get_orders(OpenOrderParams())

order_id = open_orders[0]["id"] if open_orders else None
if order_id:
    client.cancel(order_id)

client.cancel_all()

Markets (read‑only)

from py_clob_client.client import ClobClient

client = ClobClient("https://clob.kuest.com")
markets = client.get_simplified_markets()
print(markets["data"][:1])

User trades (requires auth)

Note: EOA/MetaMask users must set token allowances before trading. See Token Allowances section below.

from py_clob_client.client import ClobClient

HOST = "https://clob.kuest.com"
CHAIN_ID = 80002
PRIVATE_KEY = "<your-private-key>"
FUNDER = "<your-funder-address>"

client = ClobClient(
    HOST,  # The CLOB API endpoint
    key=PRIVATE_KEY,  # Your wallet's private key
    chain_id=CHAIN_ID,  # Polygon Amoy chain ID (80002)
    signature_type=0,  # 0 for EOA signatures
    funder=FUNDER  # Address that holds your funds
)
client.set_api_creds(client.create_or_derive_api_creds())

last = client.get_last_trade_price("<token-id>")
trades = client.get_trades()
print(last, len(trades))

Important: Token Allowances for MetaMask/EOA Users

Do I need to set allowances?

  • Using a factory proxy wallet? No action needed - allowances are set automatically.
  • Using MetaMask or hardware wallet? You need to set allowances before trading.

What are allowances?

Think of allowances as permissions. Before Kuest can move your funds to execute trades, you need to give the exchange contracts permission to access your USDC and conditional tokens.

Quick Setup

You need to approve two types of tokens:

  1. USDC (for deposits and trading)
  2. Conditional Tokens (the outcome tokens you trade)

Each needs approval for the exchange contracts to work properly.

Setting Allowances

Here's a simple breakdown of what needs to be approved:

For USDC (your trading currency):

  • Token: 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174
  • Approve for these contracts:
    • 0xB5592f7CccA122558D2201e190826276f3a661cb (Main exchange)
    • 0xef02d1Ea5B42432C4E99C2785d1a4020d2FB24F5 (Neg risk exchange)
    • 0x724259Fe88100FE18C134324C4853975FBDa4d76 (Neg risk adapter)

For Conditional Tokens (your outcome tokens):

  • Token: 0x4682048725865bf17067bd85fF518527A262A9C7
  • Approve for the same three contracts above

Example Code

See this Python example for setting allowances programmatically.

Pro tip: You only need to set these once per wallet. After that, you can trade freely.

Notes

  • To discover token IDs, use the Markets API Explorer: Get Markets.
  • Prices are in dollars from 0.00 to 1.00. Shares are whole or fractional units of the outcome token.

See /example for more.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kuest_py_clob_client-0.34.6.tar.gz (36.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kuest_py_clob_client-0.34.6-py3-none-any.whl (44.4 kB view details)

Uploaded Python 3

File details

Details for the file kuest_py_clob_client-0.34.6.tar.gz.

File metadata

  • Download URL: kuest_py_clob_client-0.34.6.tar.gz
  • Upload date:
  • Size: 36.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kuest_py_clob_client-0.34.6.tar.gz
Algorithm Hash digest
SHA256 561ed6c6f19c9dad6815a1329c3e0d33f0721c292db86a590f84ef46b64cae49
MD5 c4b1344cf4d01e5c34c648ae34c506e0
BLAKE2b-256 a58007a44696f36b3ccf67b5f0226039904a37b3d4b22947a33ae81721e15c2f

See more details on using hashes here.

Provenance

The following attestation bundles were made for kuest_py_clob_client-0.34.6.tar.gz:

Publisher: release.yaml on kuestcom/py-clob-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kuest_py_clob_client-0.34.6-py3-none-any.whl.

File metadata

File hashes

Hashes for kuest_py_clob_client-0.34.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ec534c01e2e6eaa866bd543deb7e60e1fc91160e130619aeb7081b83bd0c3a5f
MD5 c3f46d34fa37ef491c5897f68651284b
BLAKE2b-256 fec50e953053f96de17b681b34c188a28ae94e5563efac6a2462f8eae93099e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for kuest_py_clob_client-0.34.6-py3-none-any.whl:

Publisher: release.yaml on kuestcom/py-clob-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page