Skip to main content

CLI utilities for Polymarket API

Project description

polymarket-search

CI codecov GitHub tag

polymarket-search is a CLI and Python library that makes it easy to find, explore, and analyse Polymarket prediction markets via the Gamma API.

The Gamma API exposes all public market data but has no keyword search — to find events you have to page through everything. polymarket-search handles that: it fetches and caches the full event catalogue locally so you can search and filter instantly, and gives you clean access to live market prices and details.

Installation

CLI tool — puts pms in your PATH, no repo needed:

# with uv (recommended)
uv tool install git+https://github.com/L-josh/polymarket-search

# with pipx
pipx install git+https://github.com/L-josh/polymarket-search

Python library — add to an existing project:

# with uv
uv add git+https://github.com/L-josh/polymarket-search

# with pip
pip install git+https://github.com/L-josh/polymarket-search

Development — clone and work on the source:

git clone https://github.com/L-josh/polymarket-search
cd polymarket-search
uv sync

CLI (pms)

Search events

# Search active events by keyword, sorted by volume
pms event search "bitcoin"

# Require multiple keywords (all must appear in title)
pms event search "bitcoin above"

# Include ended/closed events
pms event search "election" --all

# Bypass the local cache and fetch fresh data
pms event search "bitcoin" --fresh

# Minimum volume filter (USD)
pms event search "bitcoin" --min-volume 100000

Event and market details

# Full event details with all its markets and current prices
pms event info <event_id>

# Details for a single market
pms market info <market_id>

Cache management

Events are cached at ~/.cache/polymarket-search/ and auto-refresh after 1 hour. The cache strips nested market data to keep it lean (~40 MB for ~10k active events).

pms cache refresh          # Refresh active events
pms cache refresh --all    # Include closed events

Configuration

pms config init   # Create a config file with defaults
pms config edit   # Open config in $EDITOR
pms config show   # Show active configuration
pms config path   # Show config file location

Config lives at ~/.config/polymarket-search/config.toml and lets you set default volume filters, date filters, and cache TTL.

Python library

from polymarket_search.client import GammaClient

with GammaClient() as client:
    # Search events by keyword
    events = client.get_events(active_only=True)
    bitcoin_events = [e for e in events if "bitcoin" in e.title.lower()]

    # Full event details including all markets and current prices
    event = client.get_event("424475")
    for market in event.markets:
        prices = dict(zip(market.outcomes, market.outcome_prices))
        print(f"{market.question}: {prices}")

    # Single market lookup
    market = client.get_market("2097944")
    print(f"Yes: {market.outcome_prices[0]:.1%}")

See examples/ for more, including how to find the nearest-expiry Bitcoin Up/Down markets.

Agent usage (Claude Code skill)

polymarket-search is straightforward to use from AI agents. See examples/skills/ for a ready-to-use Claude Code skill that gives Claude the ability to search and analyse Polymarket markets on your behalf.

Development

just install    # Install dependencies
just fmt        # Format code (black + ruff)
just types      # Type check (mypy)
just test       # Run tests
just check      # Run all checks
uv run pytest --cov=polymarket_search --cov-report=term-missing

License

MIT

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_search-0.1.0.tar.gz (71.1 kB view details)

Uploaded Source

Built Distribution

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

polymarket_search-0.1.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file polymarket_search-0.1.0.tar.gz.

File metadata

  • Download URL: polymarket_search-0.1.0.tar.gz
  • Upload date:
  • Size: 71.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for polymarket_search-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5525d869c593b51d92704f7824a82465a83b5f6cd11f47226a2bf2cc56174399
MD5 6399eb5873755bf79b65e6dd9e417eb9
BLAKE2b-256 46eb0c8aee4a2529e6293a8329401c8263f9155165274ec257f0fd2d7701e531

See more details on using hashes here.

Provenance

The following attestation bundles were made for polymarket_search-0.1.0.tar.gz:

Publisher: publish.yml on L-josh/polymarket-search

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polymarket_search-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for polymarket_search-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d382dd2b54fd1b5ad17a4abb486e9cf86276197f09110e0134554b329ed0a846
MD5 b67d78eea94bce47df93657bf56217ef
BLAKE2b-256 98ebdd4bea6f6355bd9ac97674db951c2b8f107e48a6d6b9f9d45d89d7105350

See more details on using hashes here.

Provenance

The following attestation bundles were made for polymarket_search-0.1.0-py3-none-any.whl:

Publisher: publish.yml on L-josh/polymarket-search

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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