Skip to content

feat(examples): add runnable Python SDK examples#122

Open
naruto11eth wants to merge 8 commits into
mainfrom
dev-134-python-sdk-examples
Open

feat(examples): add runnable Python SDK examples#122
naruto11eth wants to merge 8 commits into
mainfrom
dev-134-python-sdk-examples

Conversation

@naruto11eth

@naruto11eth naruto11eth commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Adds a runnable examples/ package so users can see the SDK in action, mirroring the ts-sdk examples/scripts/ set. Run any with uv run python -m examples.<name>.

  • Reads (no creds): list_markets, fetch_market, pagination, market_prices, search
  • Account: list_positions (needs only a wallet address)
  • Orders: create_market_order, create_limit_order — build and sign locally only, never submitted

Shared lib/ helpers (require_env, find_order_example_market, console.table-style printers) keep output at parity with the ts examples. examples/ is wired into ruff + pyright (strict); all scripts pass both, and the credential-free reads were verified live.

Refs: DEV-134


Note

Low Risk
Adds documentation and demo scripts only; no changes to SDK runtime, auth, or order submission paths.

Overview
Adds a runnable examples/ package (run via uv run python -m examples.<name>) that mirrors the TypeScript SDK example set: public reads (markets, pagination, prices, search), wallet positions, and local-only limit/market order signing.

examples/lib/ supplies shared helpers (require_env, find_order_example_market, console.table-style printers). examples/README.md documents commands and credential env vars (order scripts sign but do not post).

pyproject.toml extends ruff and pyright src/include to examples so the new scripts are linted and type-checked in strict mode.

Reviewed by Cursor Bugbot for commit fab230c. Bugbot is set up for automated code reviews on this repo. Configure here.

Add `examples` to ruff `src` and pyright `include` so the example scripts are linted and strictly type-checked alongside `src`/`tests`.
Helpers shared across the example scripts: `require_env` for required env vars, `find_order_example_market` to locate a live order-book market, and Node `console.table`-style printers for output parity with the ts-sdk examples.
List markets, fetch a single market by url/slug/id, and walk pages of a list endpoint. Run via `uv run python -m examples.<name>`; no credentials required.
Read CLOB order book/prices for a token and search events/tags/profiles. Output mirrors the ts-sdk `console.table` shape for side-by-side parity.
List a wallet's open positions. Needs only `POLYMARKET_DEPOSIT_WALLET` (a public address to inspect), no signing key.
Build and sign market and limit orders locally and print the `SignedOrder`. They never call `post_order`/`place_*` — nothing is submitted to the exchange.
Run commands, credential setup (export or `source .env`), and a note on the shared `lib/` helpers.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 27e1891. Configure here.

Comment thread examples/lib/markets.py Outdated
The order-example market filter rejected `accepting_orders` only when explicitly `False`, letting markets with it unset (`None`) through. Match the strict `enable_order_book is not True` check in the same guard so only markets confirmed to be accepting orders are selected.
@naruto11eth naruto11eth requested a review from cesarenaldi June 26, 2026 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant