Get mempool firehose connection info
https://api.triport.io/v1/polygon/firehose/mempool/connect-infoIssues a short-lived, signed WSS URL and token for subscribing to the Polygon pending-transaction (mempool) firehose.
This endpoint does not stream data itself. It returns a PolyWsConnectInfo
object — an already-signed wss:// URL plus a short-lived auth token — that you
use to open the actual mempool firehose WebSocket. The token is included as the
first frame you send on the new connection, and it expires at expires_at,
so call this endpoint immediately before connecting and refresh whenever a
connection drops or the token nears expiry.
The mempool firehose delivers Polygon pending transactions as they enter the node mempool, before they are mined into a block. A single connection sees a baseline throughput of roughly 32–37 tx/s. Use it for mempool monitoring, pre-confirmation transaction tracking, MEV/orderflow analysis, and front-running detection dashboards.
The firehose is the highest-tier Polygon product surface and requires the
business tier. Callers on a lower tier receive 403 tier_insufficient. Once
connected, the WebSocket enforces the same auth and rate-limit rules and signals
violations through the documented close codes.
For the WebSocket protocol itself — frame format, subscription messages, and
keep-alive — see the firehose channel reference at
/ws/polygon-bor-firehose.
Parameters
This endpoint takes no path, query, or body parameters. Authentication is the only required input.
AuthorizationheaderrequiredBearer $TRIPORT_API_KEY. Alternatively X-API-Key: $TRIPORT_API_KEY, or the legacy ?api-key= query parameter.Response
Response fields
| Field | Type | Description |
|---|---|---|
url | string (uri) | Already-signed wss:// URL. Open a WebSocket connection directly to this value. |
token | string | Short-lived auth token. Send it as the first frame on the opened WebSocket. |
expires_at | string (date-time) | RFC 3339 timestamp after which url/token are no longer valid. Re-request before this time. |
close_codes | object | Reference map of WebSocket close codes this firehose uses to signal errors after the connection is open (see below). |
close_codes.unauthorized | integer | 4001 — token missing, invalid, or expired. |
close_codes.forbidden | integer | 4003 — tier insufficient for this firehose. |
close_codes.rate_limited | integer | 4029 — sustained message/connection rate exceeded. |
close_codes.trial_expired | integer | 4030 — free trial period ended. |
Only url and expires_at are guaranteed present; token and close_codes
are included on success.
Errors
| Code | error | When it happens |
|---|---|---|
401 | unauthorized, trial_expired, subscription_expired | Missing/invalid credentials, or the trial/subscription period has ended. |
403 | tier_insufficient | The API key's tier is below business. The response includes current_tier, required_tier, and upgrade_url; the X-Required-Tier header is also set. |
429 | rate_limited | Sustained RPS for this category exceeded. The response includes retry_after_sec, limit_rps, and current_tier; Retry-After and X-RateLimit-* headers accompany it. |
All error bodies use the shared envelope (error, message, request_id).
See errors.md for the full schema and per-code fields.
Examples
JavaScript (fetch)
const res = await fetch(
"https://api.triport.io/v1/polygon/firehose/mempool/connect-info",
{ headers: { Authorization: `Bearer ${process.env.TRIPORT_API_KEY}` } }
);
if (!res.ok) throw new Error(`connect-info failed: ${res.status}`);
const info = await res.json();
const ws = new WebSocket(info.url);
ws.onopen = () => ws.send(info.token); // token as the first frame
ws.onmessage = (ev) => {
const pendingTx = JSON.parse(ev.data);
console.log("pending tx:", pendingTx.hash);
};
ws.onclose = (ev) => {
if (ev.code === info.close_codes.unauthorized) {
// token expired — re-request connect-info and reconnect
}
};TypeScript SDK (@triport/sdk)
import { Triport } from "@triport/sdk";
const client = new Triport({ apiKey: process.env.TRIPORT_API_KEY! });
const info = await client.polygon.firehose.mempool.connectInfo();
const stream = await client.polygon.firehose.mempool.connect(info);
for await (const tx of stream) {
console.log("pending tx:", tx.hash);
}Python (triport-sdk)
import os
from triport import Triport
client = Triport(api_key=os.environ["TRIPORT_API_KEY"])
info = client.polygon.firehose.mempool.connect_info()
with client.polygon.firehose.mempool.connect(info) as stream:
for tx in stream:
print("pending tx:", tx["hash"])Notes
- Stateless, short-lived credentials.
urlandtokenexpire atexpires_at. Always fetch fresh connect-info right before opening a socket; do not cache it across reconnects. - Throughput. Expect ~32–37 tx/s on a single connection. Pending transactions are not yet mined and may never be — handle drops/replacements on the consumer side.
- No daily cap. Rate limiting is RPS-per-tier with a burst multiplier; there is no daily quota.
- Related: the logs firehose connect-info at
/v1/polygon/firehose/logs/connect-info(pro tier), and the live WebSocket channel/ws/polygon-bor-firehose.