Advanced
Lower-level helpers for when the high-level methods aren't enough.
client.xchat.token()
Mint a short-lived realtime auth token (a JWT) for the chat WebSocket. This is the token that goes in wss://chat-ws.x.com/ws?token=... (see Protocol → Transport).
js
const jwt = await client.xchat.token();client.xchat.gql(name, variables?)
Call any known XChat GraphQL operation directly and get the raw response. Every other method in client.xchat is a wrapper over this. It throws on a GraphQL-level error.
| Param | Type | Description |
|---|---|---|
name | string | Operation name (see Protocol → GraphQL operations) |
variables | object | GraphQL variables for the operation |
js
const res = await client.xchat.gql("GetPublicKeys", { ids: ["44196397"], include_juicebox_tokens: true });Use this to reach operations that don't yet have a dedicated helper (inbox paging, message requests, groups, media upload). The full wire format for those lives in the Protocol reference.