DEV Community

BlueWhale-Quant-Lab
BlueWhale-Quant-Lab

Posted on

How to get a Polymarket event slug (and the CLOB token IDs) for Up/Down markets

How to get a Polymarket event slug (and the CLOB token IDs) for Up/Down markets

If you've tried to automate anything around Polymarket's crypto "Up or Down"
markets, you've probably hit this wall: the Gamma API will happily return an
event if you already know its slug

GET https://gamma-api.polymarket.com/events?slug=btc-updown-5m-1780319100
Enter fullscreen mode Exit fullscreen mode

— but nothing documents how to build that slug in the first place. Searching
"polymarket event slug", "polymarket get market by slug", or "polymarket clob
token id"
turns up almost nothing. Here's the format, and a small open-source
tool that does it for you.

Why the slug matters

On Polymarket the slug is the key that unlocks everything else:

slug ──/events?slug=──▶ event ──▶ markets[0].clobTokenIds ──▶ order book / price
Enter fullscreen mode Exit fullscreen mode

No slug, no market id, no CLOB token id, no condition id. So building the slug
deterministically is step one of any read or trade automation.

The easy case: 5-minute and 15-minute markets

These two timeframes use a plain UTC timestamp:

{asset}-updown-{tf}-{unix_timestamp}

btc-updown-5m-1780319100
eth-updown-15m-1780318800
Enter fullscreen mode Exit fullscreen mode

t_start is just a UTC floor:

def get_t_start(tf, now):
    dur = {"5m": 300, "15m": 900}[tf]
    return (int(now) // dur) * dur
Enter fullscreen mode Exit fullscreen mode

That's it — no timezone, no daylight saving. There's a tiny MIT-licensed tool
that builds these and (optionally) calls Gamma to hand you the token IDs:

python polymarket_slug.py btc 5m --resolve
# slug   : btc-updown-5m-1780319100
# title  : Bitcoin Up or Down - June 1, 9:05AM-9:10AM ET
# tokens : ['632187004239...', '502984638552...']
Enter fullscreen mode Exit fullscreen mode

Repo: https://github.com/BlueWhale-Quant-Lab/polymarket-updown-event-slug-generator

The hard case: 1h / 4h / 1d

The hourly, 4-hour, and daily markets are where naive code silently 404s:

  • The boundaries are Eastern Time. Hard-code a UTC-5 offset and every slug breaks for ~8 months of the year once US daylight saving (EDT, UTC-4) kicks in.
  • The 1d market runs noon-ET → noon-ET — not a UTC day, not an ET-midnight day. "...on March 5" = Mar 4 noon ET → Mar 5 noon ET, and the slug carries the settlement date: bitcoin-up-or-down-on-march-5-2026.
  • The 1h format drifted. Polymarket has shipped it both with and without the year (bitcoin-up-or-down-june-1-9am-et vs ...-june-1-2026-9am-et), so robust code has to try both and validate.
  • Watch for zombie slugs: across a year boundary the same date can resolve to last year's CLOSED market (depth 0). Filter closed/inactive.

The free tool sticks to the two deterministic timeframes on purpose. If you need
1h/4h/1d done correctly (DST-safe, format-change-proof, with the noon-ET boundary
and dynamic tickSize handled), there's a complete version here:
Polymarket Up/Down slug generator — PRO.

Wrap-up

The slug is a small thing that blocks a lot of Polymarket automation simply
because the format isn't written down anywhere. For 5m/15m it's a one-line UTC
floor; for 1h/4h/1d it's an Eastern-Time minefield. Grab the open-source generator
and save yourself the reverse-engineering:
https://github.com/BlueWhale-Quant-Lab/polymarket-updown-event-slug-generator

(Note: this is about building a data primitive and reading public market data —
not placing orders or predicting prices.)

Top comments (1)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.