Get logs firehose connection info
https://api.triport.io/v1/polygon/firehose/logs/connect-infoReturns a short-lived, signed WebSocket URL and token for connecting to the Polygon **logs firehose** — a real-time `eth_subscribe('logs', …)` event stream.
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:
- Call this endpoint over plain HTTPS with your API key to obtain a fresh
url+token. - Open the WebSocket at
url, sendtokenas the first frame, then send a standardeth_subscriberequest 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)tokenstringeth_subscribe.expires_atstring (date-time)url and token stop working (RFC 3339 / ISO 8601). Connect before this time. (required)close_codesobjectErrors
These apply to the connect-info HTTP request. Failures on the WebSocket
itself are reported via the close_codes above, not these HTTP statuses.
| Code | Meaning | When it happens |
|---|---|---|
401 | unauthorized / trial_expired / subscription_expired | Missing, invalid, or expired credentials. |
403 | tier_insufficient / method_unknown | API key's tier is below Pro, or the method is not part of the Polygon product. |
429 | rate_limited | Sustained 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/4030TypeScript 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_attheurl/tokenpair is rejected on the handshake with close code4001. - Token goes first. Send
tokenas the first WebSocket frame; only then send youreth_subscriberequest. Theurlis already signed — connect to it verbatim, do not strip or alter the query string. - Filtering. Pass a standard logs filter as the second
eth_subscribeparameter —address(a single contract or an array) andtopics(up to four indexed-topic slots,nullfor 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_codestell 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.