|
2 | 2 |
|
3 | 3 | Read-only CLI for public Polymarket Gamma, CLOB, and Data API lookups. |
4 | 4 |
|
5 | | -This repo stays intentionally narrow: public, unauthenticated reads only. It does not place orders, manage wallets, sign anything, or depend on private APIs. |
| 5 | +This package stays intentionally narrow: public, unauthenticated reads only. It does not place orders, manage wallets, sign anything, or depend on private APIs. |
6 | 6 |
|
7 | | -The published Python distribution is `polymarket-cli`, the import package is `polymarket_cli`, and the command stays `pmkt`. |
| 7 | +The published Python distribution is `polymarket-cli`, the import package is `polymarket_cli`, and the command is `polymarket-cli`. |
8 | 8 |
|
9 | | -## What `pmkt` covers |
| 9 | +## What It Covers |
10 | 10 |
|
11 | | -- market discovery via `search` and `list` |
12 | | -- market detail lookup via `market` |
13 | | -- order book and spot pricing via `book`, `midpoint`, and `price` |
14 | | -- recent public trades via `trades` |
15 | | -- public token price history via `history` |
16 | | - |
17 | | -The CLI uses only public Polymarket endpoints: |
18 | | - |
19 | | -- Gamma `GET /markets` |
20 | | -- Gamma `GET /markets/{id}` and `GET /markets/slug/{slug}` |
21 | | -- Gamma `GET /public-search` |
22 | | -- CLOB `GET /book` |
23 | | -- CLOB `GET /midpoint` |
24 | | -- CLOB `GET /last-trade-price` |
25 | | -- CLOB `GET /prices-history` |
26 | | -- Data API `GET /trades` |
| 11 | +- Market discovery via `search` and `list` |
| 12 | +- Market detail lookup via `market` |
| 13 | +- Order book and spot pricing via `book`, `midpoint`, and `price` |
| 14 | +- Recent public trades via `trades` |
| 15 | +- Public token price history via `history` |
27 | 16 |
|
28 | 17 | ## Install |
29 | 18 |
|
30 | | -### Default for a local checkout |
31 | | - |
32 | | -Use `uv tool install --editable .` for the real `pmkt` entrypoint while keeping the checkout live: |
33 | | - |
34 | 19 | ```bash |
35 | | -uv tool install --editable . |
36 | | -pmkt --help |
| 20 | +uv tool install polymarket-cli |
| 21 | +polymarket-cli --help |
37 | 22 | ``` |
38 | 23 |
|
39 | | -If uv's tool bin directory is not on your `PATH` yet: |
| 24 | +For one-off execution: |
40 | 25 |
|
41 | 26 | ```bash |
42 | | -uv tool update-shell |
43 | | -# or run the binary directly |
44 | | -"$(uv tool dir --bin)"/pmkt --help |
| 27 | +uvx polymarket-cli --help |
45 | 28 | ``` |
46 | 29 |
|
47 | | -For one-off execution without installing: |
| 30 | +If your `uv` tool bin directory is not on `PATH`, either run `uv tool update-shell` or call the binary directly from `$(uv tool dir --bin)`. |
48 | 31 |
|
49 | | -```bash |
50 | | -uvx --from . pmkt --help |
51 | | -``` |
| 32 | +## Claude Code And Codex |
52 | 33 |
|
53 | | -### Default for a published release |
| 34 | +In Claude Code or Codex, install the published CLI in the agent shell environment: |
54 | 35 |
|
55 | 36 | ```bash |
56 | 37 | uv tool install polymarket-cli |
57 | | -pmkt --help |
| 38 | +polymarket-cli search bitcoin --limit 5 |
58 | 39 | ``` |
59 | 40 |
|
60 | | -### Secondary project-mode execution |
| 41 | +For ephemeral runs inside those environments: |
61 | 42 |
|
62 | 43 | ```bash |
63 | | -uv run pmkt --help |
| 44 | +uvx polymarket-cli market --slug <market-slug> --json |
64 | 45 | ``` |
65 | 46 |
|
66 | | -## Usage |
| 47 | +If you want the agent to treat this repo as a reusable skill bundle, use the bundled skill at `skills/polymarket-cli/`. |
67 | 48 |
|
68 | | -### Market discovery |
| 49 | +## Usage |
69 | 50 |
|
70 | 51 | ```bash |
71 | | -pmkt search bitcoin --limit 5 |
72 | | -pmkt search election --sort liquidity --json |
73 | | -pmkt search iran --sort volume24hr --active-only --with-odds --limit 5 |
74 | | - |
75 | | -pmkt list --active-only --sort volume24hr --limit 20 |
76 | | -pmkt list --closed-only --sort endDate --ascending --limit 20 |
77 | | -pmkt list --tag-id 100381 --related-tags --limit 25 |
78 | | -pmkt list --min-liquidity 10000 --min-volume24hr 5000 |
| 52 | +polymarket-cli search bitcoin --limit 5 |
| 53 | +polymarket-cli list --active-only --sort volume24hr --limit 20 |
| 54 | +polymarket-cli market --slug btc-updown-5m-1774165800 |
| 55 | +polymarket-cli book --slug btc-updown-5m-1774165800 --outcome Down |
| 56 | +polymarket-cli price --slug btc-updown-5m-1774165800 |
| 57 | +polymarket-cli history --slug btc-updown-5m-1774165800 --window 6h --format summary --json |
| 58 | +polymarket-cli trades --slug btc-updown-5m-1774165800 --limit 20 |
79 | 59 | ``` |
80 | 60 |
|
81 | | -Useful options: |
| 61 | +Useful flags: |
82 | 62 |
|
83 | 63 | - `--json` is available on every command. |
84 | 64 | - `--hydrate` resolves search/list rows to full market detail before local ranking or filtering. |
85 | 65 | - `--with-odds` implies hydration and includes current outcome prices. |
86 | 66 | - `--with-market` implies hydration and embeds the resolved market payload in JSON output. |
87 | | -- Supported sort values are `volume24hr`, `volume`, `liquidity`, `startDate`, `endDate`, `competitive`, and `closedTime`. |
88 | | - |
89 | | -### Market details |
90 | | - |
91 | | -```bash |
92 | | -pmkt market --slug btc-updown-5m-1774165800 |
93 | | -pmkt market --id 1669969 --json |
94 | | -``` |
95 | | - |
96 | | -### Order book and spot pricing |
97 | | - |
98 | | -```bash |
99 | | -pmkt book --token-id 94242206871221370391055736153305071391564432448684801902267396130896523340261 |
100 | | -pmkt midpoint --token-id 94242206871221370391055736153305071391564432448684801902267396130896523340261 |
101 | | -pmkt price --slug btc-updown-5m-1774165800 |
102 | | -pmkt book --slug btc-updown-5m-1774165800 --outcome Down |
103 | | -``` |
104 | | - |
105 | | -### Price history |
106 | | - |
107 | | -```bash |
108 | | -pmkt history --token-id 94242206871221370391055736153305071391564432448684801902267396130896523340261 \ |
109 | | - --interval 1h \ |
110 | | - --fidelity 5 \ |
111 | | - --start 2026-03-22T00:00:00Z \ |
112 | | - --end 2026-03-22T12:00:00Z |
113 | | - |
114 | | -pmkt history --slug btc-updown-5m-1774165800 --outcome Down --interval 1h --window 60 --format ohlc |
115 | | -pmkt history --slug btc-updown-5m-1774165800 --window 6h --format summary --json |
116 | | -``` |
117 | | - |
118 | | -Supported history intervals: |
119 | | - |
120 | | -- `max` |
121 | | -- `all` |
122 | | -- `1m` |
123 | | -- `1h` |
124 | | -- `6h` |
125 | | -- `1d` |
126 | | -- `1w` |
127 | | - |
128 | | -### Public trades |
129 | | - |
130 | | -```bash |
131 | | -pmkt trades --slug btc-updown-5m-1774165800 --limit 20 |
132 | | -pmkt trades --condition-id 0xba3509c3c29a52bb2f8cf8204755314a38461825e61e77e6350f5abd4b848e05 --json |
133 | | -``` |
134 | | - |
135 | | -## CLI behavior |
136 | | - |
137 | | -- Text output is line-oriented by default. |
138 | | -- `--json` is available everywhere for automation. |
139 | 67 | - Market selectors are explicit: `--slug`, `--id`, `--token-id`, `--condition-id`. |
140 | | -- If no `--outcome` is given for token-resolving commands, the first market token is used. |
141 | | -- Ranked search/list JSON includes ranking metadata so downstream tools can detect fallback or degraded result sets. |
142 | | - |
143 | | -## Development |
144 | | - |
145 | | -Run tests: |
146 | | - |
147 | | -```bash |
148 | | -uv run --no-project python -m unittest discover -s tests -v |
149 | | -``` |
150 | | - |
151 | | -Build artifacts: |
152 | | - |
153 | | -```bash |
154 | | -uv build |
155 | | -``` |
156 | | - |
157 | | -Quick smoke checks: |
158 | | - |
159 | | -```bash |
160 | | -uvx --from . pmkt --help |
161 | | -uvx --from . pmkt search --help |
162 | | -``` |
163 | | - |
164 | | -The fixture-backed test suite does not require live network access. |
165 | | - |
166 | | -## Release publishing |
167 | | - |
168 | | -GitHub Actions handles publishing to TestPyPI and PyPI with trusted publishing (OIDC). No API tokens or repository secrets are required in this repo. |
169 | | - |
170 | | -Required GitHub-side setup: |
171 | | - |
172 | | -1. Configure a trusted publisher for this repository in TestPyPI. |
173 | | -2. Configure a trusted publisher for this repository in PyPI. |
174 | | -3. If you want manual approval before production release, protect the GitHub `pypi` environment. |
175 | | - |
176 | | -Workflow behavior: |
177 | 68 |
|
178 | | -- CI runs on pushes and pull requests. |
179 | | -- TestPyPI publishing runs on version tags like `v1.2.3-rc1` and by manual dispatch. |
180 | | -- PyPI publishing runs on GitHub release publication and by manual dispatch. |
| 69 | +Supported history intervals: `max`, `all`, `1m`, `1h`, `6h`, `1d`, `1w`. |
0 commit comments