npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

realtimeodds-spec

v0.5.0

Published

JSON Schema specifications for the realtimeodds public protocol — source of truth for all SDK ports.

Readme

realtimeodds-spec

JSON Schema specifications for the realtimeodds public protocol — source of truth for all SDK ports.

Status: protocol v1, MVP scope.

What this is

A language-agnostic contract describing the public surface of realtimeodds, a unified API to consume real-time betting odds from multiple bookmakers. The spec covers two distinct surfaces:

  1. Wire protocol (wire/) — what the gateway transmits to a connected SDK over WebSocket.
  2. SDK events (sdk_events/) — what each SDK port emits to its consumer after translating wire messages.

Plus shared definitions: entity schemas (SportEvent, Market, Selection, Quote, OrderBook), enums (common.schema.json), and authentication (auth.schema.json).

Layout

schemas/v1/
├── common.schema.json              # shared enums, ids, timestamps
├── sport_event.schema.json         # SportEvent (discriminated by `kind`)
├── market.schema.json              # Market (discriminated by `kind`)
├── selection.schema.json
├── quote.schema.json
├── order_book.schema.json
├── auth.schema.json
├── sdk_events/                     # SDK → consumer (uses `bookmaker`)
│   ├── sport_event_added.schema.json
│   ├── sport_event_updated.schema.json
│   ├── sport_event_removed.schema.json
│   ├── odds_changed.schema.json
│   └── lifecycle.schema.json
└── wire/                           # gateway → SDK (uses `source` = preset id)
    ├── hello.schema.json
    ├── snapshot.schema.json
    ├── preset_list.schema.json
    ├── new_event.schema.json
    ├── update_event.schema.json
    ├── prices_updated.schema.json
    ├── remove_event.schema.json
    ├── store_cleared.schema.json
    ├── preset_snapshot.schema.json
    ├── preset_updated.schema.json
    ├── preset_removed.schema.json
    └── fetcher_status.schema.json
examples/
├── sdk_events/
└── wire/

Wire protocol (gateway → SDK)

Transport

WebSocket. The client connects with its API key in the query string:

wss://gateway.example.com/?apiKey=<key>

On invalid auth, the server closes the connection before any handshake with one of:

| Close code | Meaning | |---|---| | 4001 | missing apiKey | | 4002 | invalid apiKey | | 4003 | quota / rate-limit exceeded (reserved — not enforced in current MVP) |

API keys are issued out-of-band (manual config edit on the gateway for MVP).

Message ordering

After a successful WebSocket open, the gateway streams messages in this strict order:

  1. hello — protocol handshake. MUST be the first message. Clients that receive anything else first MUST refuse the connection.
  2. snapshot — full current state across all running fetcher sources.
  3. preset_list — list of configured fetcher presets.
  4. Mutations (any order): new_event, update_event, prices_updated, remove_event, store_cleared, fetcher_status, preset_updated, preset_removed.

Source identifier

Wire messages that reference a fetcher carry source — the preset id. In current deployments the preset id often equals a Bookmaker name (e.g. "ps3838"), but it is conceptually a preset identifier. SDK ports translate source into a Bookmaker value for the public API, since the bookmaker is also recoverable from the SportEventId.

SDK events (SDK → consumer)

Each SDK port emits these events locally to its consumer after translating the wire feed:

| Event | Payload | |---|---| | sportEvent:added | { sportEvent } — first observation of a sport event. | | sportEvent:updated | { sportEvent } — any change (metadata, market list, or any odds value). | | sportEvent:removed | { bookmaker, sportEventId } — no longer reported. | | odds:changed | { bookmaker, sportEventId, marketId, selectionId, quote?, orderBook? } — per-selection price update. Fires alongside sportEvent:updated. |

Plus connection lifecycle events: connected, disconnected, reconnecting, error (see sdk_events/lifecycle.schema.json).

Entities

SportEvent, Market, Selection, Quote, OrderBook describe the wire JSON shape. Two important conventions:

  • bookmaker is not a wire field. It is recoverable from SportEventId (format vmid:<bookmaker>:<external_id>). SDK ports typically expose it as a computed property on the SportEvent class.
  • sport is not a wire field. It is recoverable from SportEventKind (se:basketball_matchbasketball). SDK ports typically expose it as a computed property too.

This keeps the wire format minimal and avoids field duplication.

SportEvent is discriminated by kind (e.g. se:basketball_match); each variant adds sport-specific fields. Market is discriminated by kind (e.g. market:basketball_match.moneyline).

Multi-source

The same underlying match (e.g. Lakers vs Celtics) reported by two bookmakers shows up as two distinct SportEvent instances with different id (and therefore different bookmaker). Cross-source comparison is a consumer concern.

Versioning

The protocol is versioned independently of any SDK port. The current major is v1 (folder schemas/v1/). Backwards-incompatible changes will introduce v2/ alongside, never silently mutate v1/. Within a major, all changes are strictly additive — see the additive-only invariant in sb-entities/PROTOCOL.md.

SDK ports

  • realtimeodds-js — TypeScript / JavaScript (Node + Browser)
  • realtimeodds-python — planned (next port)
  • realtimeodds-go — planned

License

MIT — see LICENSE.