RULE CHANGE
Account streaming
Added TypeScript and Python code example sections to WebSocket connection documentation.
What this means
The article now includes sample code in TypeScript (Node) and Python for implementing WebSocket connections, whereas previously only error codes and retry guidance were documented. The error handling content remained unchanged.
▸ View exact changes
What the page said before and after
Before Oct 11, 2026
Send your API key as a Bearer token in the Authorization header of the
WebSocket upgrade request. Read-only and read-and-trade keys both work. Live
keys (fp_live_) connect only to the live URL and test keys (fp_test_) only
to the sandbox URL. A key restricted to specific accounts streams only those
accounts. MCP sessions cannot open the stream.
A rejected upgrade returns an HTTP status with a JSON body in the same
{"error":{"code","message"}} shape as the REST API:
| Status | Meaning |
|---|---|
| 401 | Missing, invalid, revoked, or expired credential, or a key for the other environment. |
| 403 | sandbox_access_expired: sandbox access requires a challenge purchase in the last 90 days. |
| 429 | Too many sockets from your address or for this key. Wait for Retry-After and back off. |
| 503 | The service is restarting or at capacity. Retry after Retry-After with jitter. |
ts theme={null}
import WebSocket from "ws";
const socket = new WebSocket(
"wss://account-stream.myfundedperpetuals.com/v1/stream",
{ headers: { Authorization: Bearer ${process.env.FP_API_KEY} } },
);
socket.on("message", (data) => {
const frame = JSON.parse(String(data));
if (frame.type === "heartbeat") return;
console.log(frame.seq, frame.type, frame.event ?? "", frame.account_id ?? "");
});
socket.on("close", (code, reason) =>
console.log("closed", code, String(reason)),
);
python theme={null}
import asyncio, json, os
import websockets
async def main():
async with websockets.connect(
"wss://account-stream.myfundedperpetuals.com/v1/stream",
additional_headers={"Authorization": f"Bearer {os.environ['FP_API_KEY']}"},
) as socket:
async for message in socket:
frame = json.loads(message)
if frame["type"] != "heartbeat":
print(frame.get("seq"), frame["type"], frame.get("event"), frame.get("account_id"))
After Oct 20, 2026
Send your API key as a Bearer token in the Authorization header of the
WebSocket upgrade request. Read-only and read-and-trade keys both work. Live
keys (fp_live_) connect only to the live URL and test keys (fp_test_) only
to the sandbox URL. A key restricted to specific accounts streams only those
accounts. MCP sessions cannot open the stream.
A rejected upgrade returns an HTTP status with a JSON body in the same
{"error":{"code","message"}} shape as the REST API:
| Status | Meaning |
|---|---|
| 401 | Missing, invalid, revoked, or expired credential, or a key for the other environment. |
| 403 | sandbox_access_expired: sandbox access requires a challenge purchase in the last 90 days. |
| 429 | Too many sockets from your address or for this key. Wait for Retry-After and back off. |
| 503 | The service is restarting or at capacity. Retry after Retry-After with jitter. |
+ TypeScript (Node)
ts theme={null}
import WebSocket from "ws";
const socket = new WebSocket(
"wss://account-stream.myfundedperpetuals.com/v1/stream",
{ headers: { Authorization: Bearer ${process.env.FP_API_KEY} } },
);
socket.on("message", (data) => {
const frame = JSON.parse(String(data));
if (frame.type === "heartbeat") return;
console.log(frame.seq, frame.type, frame.event ?? "", frame.account_id ?? "");
});
socket.on("close", (code, reason) =>
console.log("closed", code, String(reason)),
);
+ Python
python theme={null}
import asyncio, json, os
import websockets
async def main():
async with websockets.connect(
"wss://account-stream.myfundedperpetuals.com/v1/stream",
additional_headers={"Authorization": f"Bearer {os.environ['FP_API_KEY']}"},
) as socket:
async for message in socket:
frame = json.loads(message)
if frame["type"] != "heartbeat":
print(frame.get("seq"), frame["type"], frame.get("event"), frame.get("account_id"))
Send your API key as a Bearer token in the Authorization header of the
WebSocket upgrade request. Read-only and read-and-trade keys both work. Live
keys (fp_live_) connect only to the live URL and test keys (fp_test_) only
to the sandbox URL. A key restricted to specific accounts streams only those
accounts. MCP sessions cannot open the stream.
A rejected upgrade returns an HTTP status with a JSON body in the same
{"error":{"code","message"}} shape as the REST API:
| Status | Meaning |
|---|---|
| 401 | Missing, invalid, revoked, or expired credential, or a key for the other environment. |
| 403 | sandbox_access_expired: sandbox access requires a challenge purchase in the last 90 days. |
| 429 | Too many sockets from your address or for this key. Wait for Retry-After and back off. |
| 503 | The service is restarting or at capacity. Retry after Retry-After with jitter. |
+ TypeScript (Node)
ts theme={null}
import WebSocket from "ws";
const socket = new WebSocket(
"wss://account-stream.myfundedperpetuals.com/v1/stream",
{ headers: { Authorization: Bearer ${process.env.FP_API_KEY} } },
);
socket.on("message", (data) => {
const frame = JSON.parse(String(data));
if (frame.type === "heartbeat") return;
console.log(frame.seq, frame.type, frame.event ?? "", frame.account_id ?? "");
});
socket.on("close", (code, reason) =>
console.log("closed", code, String(reason)),
);
+ Python
python theme={null}
import asyncio, json, os
import websockets
async def main():
async with websockets.connect(
"wss://account-stream.myfundedperpetuals.com/v1/stream",
additional_headers={"Authorization": f"Bearer {os.environ['FP_API_KEY']}"},
) as socket:
async for message in socket:
frame = json.loads(message)
if frame["type"] != "heartbeat":
print(frame.get("seq"), frame["type"], frame.get("event"), frame.get("account_id"))