const res = await fetch('https://app.trdrs.co/api/account/stream', {
headers: { Authorization: `Bearer ${process.env.TRDRS_API_KEY}` },
})
const decoder = new TextDecoder()
for await (const chunk of res.body!) {
// Each SSE frame: "event: <name>\ndata: <json>\n\n". Snapshot first, then live events.
process.stdout.write(decoder.decode(chunk as Uint8Array))
}curl -N 'https://app.trdrs.co/api/account/stream' \
-H "Authorization: Bearer $TRDRS_API_KEY"import requests
url = "https://app.trdrs.co/api/account/stream"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.trdrs.co/api/account/stream",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://app.trdrs.co/api/account/stream"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://app.trdrs.co/api/account/stream")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.trdrs.co/api/account/stream")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body"<string>"{
"error": "invalid_instrument"
}Stream account updates
Streams the account and its risk lock over Server-Sent Events. Content-Type: text/event-stream. Every change to the account arrives as one account event carrying the whole account at one consistent revision — the same body /api/account/snapshot serves. Every (re)connect opens with one; there is no separate snapshot event, because the first frame is simply the first. An event name is the SSE event: line and its data: line is exactly that body. Apply frames by the revision and nothing else: keep the newest frame for the accountId, drop anything at or behind it, replace your whole picture with anything ahead of it (a row absent from a frame is closed or cancelled). A frame that skips revisions is still complete, so there is nothing to recover. Never compute a revision of your own. Exits are account state, so a frame carries brackets and managedExits at the same revision as the rest of it; there is no channel outside the frame. The risk lock rides the stream as its own lock event. broker/account scope the stream to one connected account.
const res = await fetch('https://app.trdrs.co/api/account/stream', {
headers: { Authorization: `Bearer ${process.env.TRDRS_API_KEY}` },
})
const decoder = new TextDecoder()
for await (const chunk of res.body!) {
// Each SSE frame: "event: <name>\ndata: <json>\n\n". Snapshot first, then live events.
process.stdout.write(decoder.decode(chunk as Uint8Array))
}curl -N 'https://app.trdrs.co/api/account/stream' \
-H "Authorization: Bearer $TRDRS_API_KEY"import requests
url = "https://app.trdrs.co/api/account/stream"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.trdrs.co/api/account/stream",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://app.trdrs.co/api/account/stream"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://app.trdrs.co/api/account/stream")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.trdrs.co/api/account/stream")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body"<string>"{
"error": "invalid_instrument"
}