j7tracker

Connect

Connect to the live tweet and socials feed.

The feed streams every event for the accounts J7 tracks, your custom accounts and every social platform. It's a Socket.IO v4 server, so use a Socket.IO client (a plain WebSocket won't work).

HostRegion
https://nyc.j7tracker.ioNA East
https://dfw.j7tracker.ioNA Central

Both carry the same feed. GET <host>/api/health returns 200 when a box is up.

  1. Connect with transports: ['websocket'] and your JWT in auth.token.
  2. On every connect (reconnects too), emit user_connected with the same JWT. Nothing arrives until you do.
  3. You get initialTweets (the backlog), then live events.
import { io } from "socket.io-client"; // npm i socket.io-client@4

const JWT = "<jwt>";
const socket = io("https://nyc.j7tracker.io", {
  transports: ["websocket"],
  auth: { token: JWT },
});

socket.on("connect", () => socket.emit("user_connected", JWT));
socket.on("connect_error", (err) => console.error(err.message));
socket.on("auth_error", (e) => console.error(e.error));

const posts = new Map();
const upsert = (t) => posts.set(t.id, { ...posts.get(t.id), ...t });

socket.on("initialTweets", (items) => { posts.clear(); items.forEach(upsert); });
socket.on("tweet", upsert);
socket.on("tweet_update", upsert);
socket.on("external_message", (m) => console.log(m.platform, m.author?.handle, m.text));
import socketio  # pip install "python-socketio[client]"

JWT = "<jwt>"
sio = socketio.Client()
posts = {}

def upsert(t):
    posts[t["id"]] = {**posts.get(t["id"], {}), **t}

@sio.event
def connect():
    sio.emit("user_connected", JWT)

@sio.on("initialTweets")
def initial(items):
    posts.clear()
    for t in items:
        upsert(t)

sio.on("tweet", upsert)
sio.on("tweet_update", upsert)
sio.on("external_message", lambda m: print(m.get("platform"), m.get("author", {}).get("handle"), m.get("text")))
sio.on("auth_error", lambda e: print(e.get("error")))

sio.connect("https://nyc.j7tracker.io", transports=["websocket"], auth={"token": JWT})
sio.wait()

Good to know

  • Dedupe by id. A post arrives once as tweet, then as tweet_updates as it fills in. See How a post arrives.
  • You get every main-feed account (minus ones you removed), your custom and available accounts flagged isCustomAccount: true, and every social post.
  • Optional: emit ping and the server replies pong, handy for measuring latency.
  • Limits and connect errors are on Errors & Limits.

On this page