Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polymarket_api_py-0.1.0.tar.gz (38.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

polymarket_api_py-0.1.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

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

Hashes for polymarket_api_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a9804e143eb800b6b89045c68307728b634b56bad24f4c6d7d87f05cbb2e1bfe
MD5 302bf27a49de025d14de8a4da00f5f45
BLAKE2b-256 910e0c4d39c5f9cd00fd34a37189209a9c5b2d8b2aacfafac36be3b594595c39

See more details on using hashes here.

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

Hashes for polymarket_api_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ed712a2b70e2b79b548407a11666ca968c26a2a8a37797e1b1c170db912d75e
MD5 4b5bb642fcdca64ddea12650699aaf59
BLAKE2b-256 f0451e84ff9d5879a0cde449161af930e0dc41ad9a931d904a6e8ba2d9c78899

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page