probnode

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

probnode-go

Go client for the probnode Live API: every Polymarket book update and trade of the markets you subscribe to, as it happens, over one WebSocket - each enriched with the probnode object (analytics, risk against the normal for similar markets, security, stats). JSON or Probe, our binary format; reconnects and resubscribes for you.

go get github.com/probnode/probnode-go
c, err := probnode.DialWith(ctx, "wss://live.probnode.com/v2/live", key,
	probnode.Options{Format: probnode.Probe, Reconnect: true})
err = c.Subscribe(ctx, []string{"btc-updown-15m-1795366800"}, []string{"book+", "trades+"}, nil)
for {
	m, err := c.Next(ctx)
	// m.JSON for JSON frames; m.Records ([]pnb.Record) for Probe frames
}

Without a key you are on the Free plan. pnb decodes Probe records on their own (pnb.Decode), for files of the archive as well as the stream.

Apache-2.0.

Documentation

Overview

Package probnode reads the real-time stream `/v2/live` from Go: connect with an account's API key, subscribe markets and channels, and read messages - JSON objects, or Probe records (pnb) when the connection asked for `format: probe`.

c, err := probnode.Dial(ctx, "wss://live.probnode.com/v2/live", key, probnode.Probe)
// or, over dropped connections: probnode.DialWith(ctx, url, key, probnode.Options{Format: probnode.Probe, Reconnect: true})
err = c.Subscribe(ctx, []string{"btc-updown-15m-1795366800"}, []string{"book+", "trades+"}, nil)
for {
	m, err := c.Next(ctx)
	...
	for _, r := range m.Records { if p, ok := r.(*pnb.ProbnodeExt); ok { ... } }
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is one connection.

func Dial

func Dial(ctx context.Context, url, key string, format Format) (*Client, error)

Dial connects; key is the account's API key ("" = Free).

func DialWith

func DialWith(ctx context.Context, url, key string, opt Options) (*Client, error)

DialWith connects with options.

func (*Client) Close

func (c *Client) Close() error

Close ends the connection; no reconnect follows.

func (*Client) Next

func (c *Client) Next(ctx context.Context) (Message, error)

Next reads the next frame. With Reconnect, a dropped connection is reopened and resubscribed here and reading goes on; Close (or ctx) ends it.

func (*Client) Subscribe

func (c *Client) Subscribe(ctx context.Context, markets, channels, blocks []string) error

Subscribe watches markets on channels; blocks picks the probnode blocks (nil = all).

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(ctx context.Context, markets []string) error

Unsubscribe stops watching markets (every channel of them).

type Format

type Format string

Format of a connection.

const (
	JSON  Format = "json"
	Probe Format = "probe"
)

type Message

type Message struct {
	JSON    map[string]any
	Records []pnb.Record
	// Unknown counts records of types this build does not know (skipped by their length).
	Unknown int
}

Message is one frame: a JSON object (JSON set) or the Probe records of a binary frame.

type Options

type Options struct {
	Format Format
	// Reconnect reopens a dropped connection (backing off 0.5 s to 30 s) and sends every active
	// subscription again; each starts with a fresh snapshot.
	Reconnect bool
	// OnGap, when set, gets the wall-clock stretch nothing was received, after a reconnect.
	OnGap func(from, to time.Time)
	// Compress offers permessage-deflate: less bandwidth, more CPU on both ends.
	Compress bool
}

Options of a connection.

Directories

Path Synopsis
examples
stream command
Stream the current 15-minute BTC up-or-down market: book+ and trades+, with the probnode object.
Stream the current 15-minute BTC up-or-down market: book+ and trades+, with the probnode object.
Package pnb is the probnode binary encoding: one fixed-width, little-endian record layout used in the engine's memory, on the wire and in the archive, so nothing is re-encoded between them (docs/LIVE.md, "Format: PNB"; after Databento's DBN).
Package pnb is the probnode binary encoding: one fixed-width, little-endian record layout used in the engine's memory, on the wire and in the archive, so nothing is re-encoded between them (docs/LIVE.md, "Format: PNB"; after Databento's DBN).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL