Skip to content

Commit 197005c

Browse files
committed
docs: make polymarket-cli the only public command
1 parent 0b707f4 commit 197005c

6 files changed

Lines changed: 85 additions & 223 deletions

File tree

README.md

Lines changed: 29 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -2,179 +2,68 @@
22

33
Read-only CLI for public Polymarket Gamma, CLOB, and Data API lookups.
44

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.
66

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`.
88

9-
## What `pmkt` covers
9+
## What It Covers
1010

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`
2716

2817
## Install
2918

30-
### Default for a local checkout
31-
32-
Use `uv tool install --editable .` for the real `pmkt` entrypoint while keeping the checkout live:
33-
3419
```bash
35-
uv tool install --editable .
36-
pmkt --help
20+
uv tool install polymarket-cli
21+
polymarket-cli --help
3722
```
3823

39-
If uv's tool bin directory is not on your `PATH` yet:
24+
For one-off execution:
4025

4126
```bash
42-
uv tool update-shell
43-
# or run the binary directly
44-
"$(uv tool dir --bin)"/pmkt --help
27+
uvx polymarket-cli --help
4528
```
4629

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)`.
4831

49-
```bash
50-
uvx --from . pmkt --help
51-
```
32+
## Claude Code And Codex
5233

53-
### Default for a published release
34+
In Claude Code or Codex, install the published CLI in the agent shell environment:
5435

5536
```bash
5637
uv tool install polymarket-cli
57-
pmkt --help
38+
polymarket-cli search bitcoin --limit 5
5839
```
5940

60-
### Secondary project-mode execution
41+
For ephemeral runs inside those environments:
6142

6243
```bash
63-
uv run pmkt --help
44+
uvx polymarket-cli market --slug <market-slug> --json
6445
```
6546

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/`.
6748

68-
### Market discovery
49+
## Usage
6950

7051
```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
7959
```
8060

81-
Useful options:
61+
Useful flags:
8262

8363
- `--json` is available on every command.
8464
- `--hydrate` resolves search/list rows to full market detail before local ranking or filtering.
8565
- `--with-odds` implies hydration and includes current outcome prices.
8666
- `--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.
13967
- 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:
17768

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`.

polymarket_cli/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def _resolve_market_filters(args: argparse.Namespace) -> dict[str, Any]:
185185

186186
def build_parser() -> argparse.ArgumentParser:
187187
parser = argparse.ArgumentParser(
188-
prog="pmkt",
188+
prog="polymarket-cli",
189189
description="Read-only Polymarket Gamma + CLOB CLI for market discovery, price snapshots, trades, and history",
190190
)
191191
sub = parser.add_subparsers(dest="command", required=True)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ license = { text = "MIT" }
1313
dependencies = []
1414

1515
[project.scripts]
16-
pmkt = "polymarket_cli.cli:main"
16+
polymarket-cli = "polymarket_cli.cli:main"
1717

1818
[tool.uv.build-backend]
1919
module-name = "polymarket_cli"

skills/pmkt/SKILL.md

Lines changed: 0 additions & 81 deletions
This file was deleted.

skills/polymarket-cli/SKILL.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
name: polymarket-cli
3+
description: Use the polymarket-cli command for read-only Polymarket market discovery, market/token resolution, price snapshots, history, trades, and JSON-safe scripting.
4+
---
5+
6+
# Using `polymarket-cli`
7+
8+
Use this skill when an agent needs public, read-only Polymarket data from this package without calling Gamma, CLOB, or Data API endpoints directly.
9+
10+
Install the published CLI:
11+
12+
```bash
13+
uv tool install polymarket-cli
14+
polymarket-cli --help
15+
```
16+
17+
For one-off execution without installing:
18+
19+
```bash
20+
uvx polymarket-cli --help
21+
```
22+
23+
## When to use `polymarket-cli`
24+
25+
- Discover markets by keyword, liquidity, volume, tags, or date windows.
26+
- Resolve a market `slug` or `id` into a `conditionId` or outcome `token_id`.
27+
- Pull spot pricing with `book`, `midpoint`, or `price`.
28+
- Pull recent public trades for a market condition.
29+
- Pull token price history and locally aggregate it into OHLC or summaries.
30+
- Produce scriptable JSON output for another tool or agent step.
31+
32+
## Command patterns
33+
34+
```bash
35+
polymarket-cli search bitcoin --limit 5
36+
polymarket-cli list --active-only --sort liquidity --min-liquidity 10000
37+
polymarket-cli market --slug <market-slug> --json
38+
polymarket-cli book --slug <market-slug> --outcome Yes
39+
polymarket-cli history --slug <market-slug> --window 6h --format summary --json
40+
polymarket-cli trades --condition-id <condition-id> --json
41+
```
42+
43+
## Working rules
44+
45+
- Prefer `polymarket-cli` in docs, prompts, and automation.
46+
- Prefer `--json` whenever another step will parse the result.
47+
- Use explicit selectors: `--slug`, `--id`, `--token-id`, `--condition-id`.
48+
- Keep usage read-only. This package does not place orders, manage wallets, or use private/authenticated APIs.

tests/test_cli.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ def test_search_uses_search_markets_for_query(self):
111111
),
112112
)
113113

114+
def test_parser_uses_public_command_name(self):
115+
parser = cli.build_parser()
116+
117+
self.assertEqual(parser.prog, "polymarket-cli")
118+
self.assertIn("usage: polymarket-cli", parser.format_help())
119+
114120
def test_list_passes_advanced_filtering_flags(self):
115121
rc, output, client = self.run_cli(
116122
[

0 commit comments

Comments
 (0)