Metadata-Version: 2.4
Name: polymarket-api-py
Version: 0.1.0
Summary: Pydantic models for the Polymarket Gamma and Data APIs.
Project-URL: Homepage, https://github.com/denizsurmeli/polymarket-api-py
Project-URL: Repository, https://github.com/denizsurmeli/polymarket-api-py
Project-URL: Issues, https://github.com/denizsurmeli/polymarket-api-py/issues
Author-email: Deniz Surmeli <denizsurmeli@icloud.com>
License-Expression: MIT
License-File: LICENSE
Keywords: async,httpx,openapi,polymarket,pydantic
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Typing :: Typed
Requires-Python: >=3.14
Requires-Dist: httpx==0.28.1
Requires-Dist: pydantic==2.13.3
Provides-Extra: regen
Requires-Dist: datamodel-code-generator==0.56.1; extra == 'regen'
Description-Content-Type: text/markdown

# polymarket-api-py

Pydantic models for the [Polymarket](https://polymarket.com) **Gamma** and **Data** APIs (read-only, no auth).

## Install

```bash
uv add polymarket-api-py
```

Requires Python 3.14+.

## Usage

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

```bash
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](LICENSE).
