On the wire · 04:45:53 UTC Live 550 · Prematch 14,363 · Markets 56,939 Vol. I · No. 5 · Friday 13 November 2026 wss://pinnfeed.io/v1/stream
PinnFeed
Risposta · Python · WebSocket

WebSocket delle quote Pinnacle: esempio Python

Aggiornato il · PinnFeed · 2 min di lettura

Risposta: installa websockets, imposta PINNFEED_KEY, collegati a wss://pinnfeed.io/v1/stream con l'header x-api-key, invia un messaggio subscribe, applica ogni snapshot/delta, rispondi a ping con {"type":"pong"} e riconnettiti con backoff esponenziale. Serve il piano Builder (99 €/mese): le chiavi Free e Hobby ricevono 403 plan_lacks_ws.

Client minimo#

pip install websockets
export PINNFEED_KEY="ps_live_..."
import asyncio, json, os, random
import websockets

WS = "wss://pinnfeed.io/v1/stream"
KEY = os.environ["PINNFEED_KEY"]

async def main():
    delay = 1
    while True:
        try:
            async with websockets.connect(WS, additional_headers={"x-api-key": KEY}, max_size=None) as ws:
                await ws.send(json.dumps({
                    "type": "subscribe",
                    "sports": ["soccer", "tennis"],
                    "markets": ["moneyline"],
                    "main": True,
                    "specials": False,
                }))
                async for raw in ws:
                    msg = json.loads(raw)
                    if msg["type"] == "ping":
                        await ws.send('{"type":"pong"}')
                    elif msg["type"] == "snapshot" and msg.get("final"):
                        print("snapshot pronto")
                        delay = 1
                    elif msg["type"] == "delta":
                        for c in msg["changes"]:
                            if c["kind"] == "market" and c["op"] == "upsert":
                                m = c["market"]
                                if (m["maxStake"] or 0) >= 100:
                                    print(m["id"], [(o["name"], o["decimal"], o["fair"]) for o in m["outcomes"]])
        except (OSError, websockets.ConnectionClosed) as e:
            print("disconnesso", e, "riprovo tra", delay, "s")
        await asyncio.sleep(delay + random.random())
        delay = min(delay * 2, 30)

asyncio.run(main())

Campi di ogni esito: decimal, american, fair (senza margine), fairProb. L'id del mercato è eventId:key. Il filtro maxStake >= 100 scarta i mercati poco liquidi. Elenco completo dei frame: docs WebSocket.

Codici di chiusura#

CodiceSignificato
4002 no_subscriptionNessun subscribe entro 30 s
4008 slow_consumerClient troppo lento (buffer del server oltre 16 MB)
4001 key_revokedChiave revocata: non riconnetterti in loop

Builder: prova di 3 giorni dai prezzi; serve una carta, addebitata dopo il giorno 3 salvo disdetta. Oppure inizia con una chiave REST gratuita. Vedi anche push o polling.

Contenuto educativo per maggiorenni (18+): documentazione tecnica, non pronostici né promesse di guadagno.

Domande frequenti#

Perché la mia chiave Free riceve 403 sul WebSocket?#

Free e Hobby sono solo REST. Passa a Builder per il push, oppure interroga /v1/odds su Free (30 s di ritardo) o Hobby (tempo reale).

Devo rispondere ai ping?#

Sì. Il server invia ping ogni 20 secondi; senza pong per 60 s la connessione viene chiusa.

Quante connessioni?#

Builder ne consente 3 simultanee, Pro 10. Oltre: 429 connection_limit.

Il piano WebSocket: Builder, 99 €/mese.

Quote Pinnacle in tempo reale su un unico WebSocket: tutti i 13 sport, tutti i mercati, quote eque senza margine e quote di chiusura. 3 giorni gratis, disdici con un clic.

Form K-1 · Free API key

Get your free API key.

One field. No password, no card: enter your email, click the link we send, and your key is on screen.

By continuing you agree to the Terms and Privacy Policy.

One free key per email. Link valid for 20 minutes.