TriportRPC

Get logs firehose connection info

GEThttps://api.triport.io/v1/polygon/firehose/logs/connect-info

Returns a short-lived, signed WebSocket URL and token for connecting to the Polygon **logs firehose** — a real-time `eth_subscribe('logs', …)` event stream.

Polygoncategory polygon_firehosePro tier or higher — RPS-per-tier with 2× burst

This is a handshake endpoint. It does not stream anything itself — instead it returns the credentials your client needs to open the Polygon logs firehose over WebSocket: an already-signed WSS url, a short-lived token, and an expires_at timestamp. Once connected, the firehose delivers a real-time stream of eth_subscribe('logs', …) events — every log entry matching your topic / address filter, pushed as it lands on chain.

The flow is two steps:

  1. Call this endpoint over plain HTTPS with your API key to obtain a fresh url + token.
  2. Open the WebSocket at url, send token as the first frame, then send a standard eth_subscribe request with "logs" and an optional filter.

The signed url and token are short-lived — they are minted per request and stop working after expires_at. Fetch a fresh pair immediately before connecting; do not cache or share them. If a connection drops, request new connect-info before reconnecting rather than reusing the old credentials.

The endpoint is gated at Pro: the underlying log stream is a high-throughput real-time canal, so it carries a higher tier requirement than the one-shot wallet and balance reads. For the protocol details of the WebSocket session itself — subscription parameters, notification envelopes, and unsubscribe — see the Polygon WebSocket guide.

Parameters

This endpoint takes no path, query, or body parameters. Authentication is the only input.

Response

200 OK with a PolyWsConnectInfo body:

urlstring (uri)
Already-signed WSS URL to connect to. Open it as-is — the signature is embedded in the query string. (required)
tokenstring
Short-lived auth token. Send it as the first WebSocket frame after the connection opens, before any eth_subscribe.
expires_atstring (date-time)
Instant after which url and token stop working (RFC 3339 / ISO 8601). Connect before this time. (required)
close_codesobject
Reference of the WebSocket close codes this firehose uses. See below.

Errors

These apply to the connect-info HTTP request. Failures on the WebSocket itself are reported via the close_codes above, not these HTTP statuses.

CodeMeaningWhen it happens
401unauthorized / trial_expired / subscription_expiredMissing, invalid, or expired credentials.
403tier_insufficient / method_unknownAPI key's tier is below Pro, or the method is not part of the Polygon product.
429rate_limitedSustained RPS for the polygon_firehose category exceeded. Honor the Retry-After header.

Example 403 body (tier below Pro):

{
  "error": "tier_insufficient",
  "message": "polygon_firehose requires the pro tier",
  "request_id": "req_7d2e9f1a4c6b",
  "current_tier": "basic",
  "required_tier": "pro",
  "category": "polygon_firehose",
  "method": "polygonFirehoseLogsConnectInfo",
  "upgrade_url": "https://api.triport.io/billing/upgrade"
}

429 responses also carry Retry-After, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, and X-RateLimit-Category headers. See the shared error reference for the full envelope and every error code.

Examples

JavaScript (fetch)

// 1. Fetch fresh connect-info.
const res = await fetch(
  "https://api.triport.io/v1/polygon/firehose/logs/connect-info",
  { headers: { Authorization: `Bearer ${process.env.TRIPORT_API_KEY}` } }
);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const { url, token } = await res.json();


// 2. Open the firehose, authenticate, then subscribe to logs.
const ws = new WebSocket(url);
ws.onopen = () => {
  ws.send(token); // first frame: the short-lived token
  ws.send(JSON.stringify({
    jsonrpc: "2.0",
    id: 1,
    method: "eth_subscribe",
    params: [
      "logs",
      { address: "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619" } // WMATIC
    ],
  }));
};
ws.onmessage = (e) => {
  const msg = JSON.parse(e.data);
  if (msg.method === "eth_subscription") console.log(msg.params.result);
};
ws.onclose = (e) => console.warn(`closed: ${e.code}`); // 4001/4003/4029/4030

TypeScript SDK (@triport/sdk)

import { Triport } from "@triport/sdk";


const client = new Triport({ apiKey: process.env.TRIPORT_API_KEY! });


// The SDK fetches connect-info, opens the signed WS, and sends the token for you.
const stream = await client.polygon.firehose.logs.subscribe({
  address: "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
});


for await (const log of stream) {
  console.log(log.transactionHash, log.topics);
}

Python (triport-sdk)

import os
from triport import Triport


client = Triport(api_key=os.environ["TRIPORT_API_KEY"])


# subscribe() fetches connect-info, opens the signed WS, and authenticates.
with client.polygon.firehose.logs.subscribe(
    address="0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619"
) as stream:
    for log in stream:
        print(log.transaction_hash, log.topics)

Notes

  • Credentials are short-lived. Always fetch fresh connect-info right before connecting. After expires_at the url/token pair is rejected on the handshake with close code 4001.
  • Token goes first. Send token as the first WebSocket frame; only then send your eth_subscribe request. The url is already signed — connect to it verbatim, do not strip or alter the query string.
  • Filtering. Pass a standard logs filter as the second eth_subscribe parameter — address (a single contract or an array) and topics (up to four indexed-topic slots, null for a wildcard). With no filter you receive every log on chain.
  • Reconnect on close. Treat a closed connection as normal operation; reconnect with backoff after requesting new connect-info. The close_codes tell you whether the close was an auth (4001/4003/4030) or rate (4029) issue versus a transient drop.
  • For the full WebSocket protocol (subscription types, notification shapes, eth_unsubscribe), see the Polygon WebSocket guide.
  • For a continuous stream of pending transactions instead of logs, use the mempool firehose connect-info endpoint (Business tier). For one-shot reads of pool state, see Get mempool snapshot.