feat(examples): add runnable Python SDK examples#122
Open
naruto11eth wants to merge 8 commits into
Open
Conversation
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.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds a runnable
examples/package so users can see the SDK in action, mirroring the ts-sdkexamples/scripts/set. Run any withuv run python -m examples.<name>.list_markets,fetch_market,pagination,market_prices,searchlist_positions(needs only a wallet address)create_market_order,create_limit_order— build and sign locally only, never submittedShared
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 viauv 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.mddocuments commands and credential env vars (order scripts sign but do not post).pyproject.tomlextends ruff and pyrightsrc/includetoexamplesso 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.