On the wire · 04:34:17 UTC Live 547 · Prematch 14,368 · Markets 56,819 Vol. I · No. 5 · Friday 13 November 2026 wss://pinnfeed.io/v1/stream
PinnFeed
Risposta · Node.js · WebSocket

Applicare snapshot e delta Pinnacle in una Map Node

Aggiornato il · PinnFeed · 1 min di lettura

Risposta: dopo subscribe, applica le parti dello snapshot in una Map con chiave l'id di mercato (eventId:key), poi ogni changes[] dei delta (upsert / remove). Client completo: guida Python/Node. Serve Builder (99 €/mese).

Logica di merge#

import WebSocket from "ws";

const markets = new Map(); // id -> market object
const KEY = process.env.PINNFEED_KEY;

function applyChange(ch) {
  if (ch.op === "upsert" || ch.type === "upsert") {
    const m = ch.market || ch.value;
    markets.set(m.id, m);
  } else if (ch.op === "remove" || ch.type === "remove") {
    markets.delete(ch.id || ch.marketId);
  }
}

const ws = new WebSocket("wss://pinnfeed.io/v1/stream", {
  headers: { "x-api-key": KEY },
  perMessageDeflate: true,
});

ws.on("open", () => {
  ws.send(JSON.stringify({
    type: "subscribe",
    sports: ["soccer"],
    markets: ["moneyline"],
    main: true,
  }));
});

ws.on("message", (buf) => {
  const msg = JSON.parse(buf.toString());
  if (msg.type === "ping") return ws.send(JSON.stringify({ type: "pong" }));
  if (msg.type === "snapshot" || msg.part != null) {
    for (const m of msg.markets || []) markets.set(m.id, m);
  }
  if (msg.type === "delta" && Array.isArray(msg.changes)) {
    for (const ch of msg.changes) applyChange(ch);
  }
});

I nomi dei campi seguono la doc WebSocket. Piani a pagamento: prova di 3 giorni; carta richiesta, addebitata dopo il giorno 3 salvo disdetta.

Vedi anche: snapshot e delta · riconnessione Node · frame grezzi (Pro).

Contenuto educativo per maggiorenni (18+): non pronostici né promesse di guadagno. In Italia scommetti solo con operatori autorizzati ADM.

Domande frequenti#

Gli eventi si fondono allo stesso modo?#

Sì — tieni una seconda Map per gli eventi se ti servono i metadati home/away; snapshot e delta possono portarli entrambi.

Perché Builder?#

Le chiavi Free/Hobby ricevono 403 plan_lacks_ws sul WebSocket. Il polling REST funziona su Free; il push richiede Builder o Pro.

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.