Pydantic models for the Polymarket Gamma and Data APIs.
Project description
polymarket-api-py
Pydantic models for the Polymarket Gamma and Data APIs (read-only, no auth).
Install
uv add polymarket-api-py
Requires Python 3.14+.
Usage
import asyncio
import httpx
from polymarket.gamma import BASE_URL
from polymarket.gamma.models import Market
async def list_open_markets(limit: int = 10) -> list[Market]:
async with httpx.AsyncClient(base_url=BASE_URL, timeout=30.0) as http:
r = await http.get("/markets", params={"limit": limit, "closed": False})
r.raise_for_status()
return [Market.model_validate(x) for x in r.json()]
asyncio.run(list_open_markets())
Regenerating models
The [regen] extra brings in datamodel-code-generator. The entrypoint reads vendored specs from specs/ and rewrites polymarket/{api}/models.py.
uv sync --extra regen
uv run polymarket-regen # default APIs from cached specs
uv run polymarket-regen --refetch # re-download specs first
uv run polymarket-regen --refetch clob # one API only
uv run polymarket-regen --list # show known APIs
Known APIs: gamma, data, clob, relayer, bridge. Only gamma and data are generated by default.
License
MIT - see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file polymarket_api_py-0.1.0.tar.gz.
File metadata
- Download URL: polymarket_api_py-0.1.0.tar.gz
- Upload date:
- Size: 38.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9804e143eb800b6b89045c68307728b634b56bad24f4c6d7d87f05cbb2e1bfe
|
|
| MD5 |
302bf27a49de025d14de8a4da00f5f45
|
|
| BLAKE2b-256 |
910e0c4d39c5f9cd00fd34a37189209a9c5b2d8b2aacfafac36be3b594595c39
|
File details
Details for the file polymarket_api_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: polymarket_api_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ed712a2b70e2b79b548407a11666ca968c26a2a8a37797e1b1c170db912d75e
|
|
| MD5 |
4b5bb642fcdca64ddea12650699aaf59
|
|
| BLAKE2b-256 |
f0451e84ff9d5879a0cde449161af930e0dc41ad9a931d904a6e8ba2d9c78899
|