Skip to content

Wire format

jetfuel.decode(buffer)

Decode an already-fetched payload (a Buffer, ArrayBuffer, typed array, or binary string) into a structured tree. This is the same decoder page, remote and res.decode() use.

js
const res = await client.jetfuel.raw("creators/inspiration/top_posts");
const tree = client.jetfuel.decode(res.buffer);

Returns:

FieldDescription
frame{ payloadLen, count, footer }: the 11-byte framing header.
tokensEvery decoded element in order, each tagged string / node / atom / list / raw with its byte offset.
stringsEvery length-prefixed UTF-8 string, in order.
nodes[{ type, key }]: each component node (0x11 intro) paired with the two strings that name it.
atoms[{ field, hash }]: interned style/property references (the hash is a FarmHash u32).
lists[{ kind, count, hashes }]: typed reference lists (children, style sets, variants).
timelineTokensAny base64 Timeline: tokens embedded in the payload.
js
tree.frame;            // { payloadLen: 27389, count: 181, footer: "b40600" }
tree.strings;          // ["page", "inspiration_top_posts", "Country", "United States", ...]
tree.nodes;            // [{ type: "page", key: "inspiration_top_posts" }, { type: "select_country", key: "event_info" }, ...]
tree.timelineTokens;   // ["VGltZWxpbmU6..."]

The format, briefly

  • Framing. uint16 LE payload length, three zero bytes, a uint8 count/version, then the payload, ending in a 3-byte footer.
  • Strings. Inline, single-byte length prefix, UTF-8: <len> <bytes>.
  • Node intro 0x11. Begins a component, followed by its [typeString, keyString].
  • Atom reference 02 <fieldId> 00 00 00 <hash:u32>. Binds a property slot to a globally interned style atom, identified by a 4-byte FarmHash. The same hash recurs across pages (a content-addressed dictionary), which is why the decoder surfaces them but cannot name them: the atom dictionary lives in a lazy client chunk.
  • Reference list 03 <kind> <count> 00 00 00 00 <hash:u32 × count>. A typed collection of references.

The decode is best-effort and structural. It reliably recovers framing, strings, the node tree, atom references and reference lists. It does not resolve interned atoms to their style definitions, and the leading symbol-table region produces some short noise strings. Treat the output as inspectable structure, not a stable schema.

Timeline: tokens

The creator-inspiration feed (remote/urt) does not return tweets. It returns a base64-encoded Timeline:<thrift> token that the main timeline service resolves via GenericTimelineById. The thrift struct carries three string fields: engagement (id 1), country (id 3), period (id 6).

emusks both builds and decodes these. They are exported from the parser:

js
import { buildTimelineToken, decodeTimelineToken } from "emusks/src/parsers/jetfuel.js";

const token = buildTimelineToken({ engagement: "Likes", country: "PRT", period: "Daily" });
// "VGltZWxpbmU6DADKCwABAAAABUxpa2VzCwADAAAAA1BSVAsABgAAAAVEYWlseQAA"

decodeTimelineToken(token);
// { engagement: "Likes", country: "PRT", period: "Daily" }

Because the token is deterministic, topPosts builds it locally and skips the binary feed entirely. buildTimelineToken produces byte-identical output to what the live server returns for the same parameters.

extractTimelineTokens(buffer)

Scan any payload for embedded base64 Timeline: tokens. Also exported from the parser, and surfaced as timelineTokens on every decode.

js
import { extractTimelineTokens } from "emusks/src/parsers/jetfuel.js";

const res = await client.jetfuel.raw("creators/inspiration/remote/urt", { params: { engagement: "Likes" } });
extractTimelineTokens(res.buffer); // ["VGltZWxpbmU6..."]

not affiliated with X Corp.