Skip to main content
rocksky is a typed, pipe-friendly Gleam client.

At a glance

Every endpoint returns a rocksky.Request(a). Refine it with chainable helpers, then send it through a Client:

Design

  • One Client, one pipe. Build the client once, then every call reads as endpoint(...) |> rocksky.<param>(...) |> ... |> rocksky.send(client).
  • No Option(_) at the call site. Required params land in the endpoint constructor; optional params chain as functions on the Request(a) value.
  • Builders for body-heavy procedures. scrobble.create, song.create, shout.create, etc. accept a typed builder.
  • Request(a) is just data. It carries the method, params, headers, body and decoder. You can decorate it (rocksky.header for per-request headers) and only at send does the network happen.
  • Errors are explicit. RocksyError distinguishes transport errors, XRPC errors, raw HTTP failures, and decode failures.
  • Swappable transport. rocksky.with_send lets you plug in your own HTTP function (great for tests; required if you target JavaScript).

Configuration

Builder vocabulary

These helpers live in the rocksky module and work on any Request(a): Namespace-specific params (e.g. charts.with_artist_uri, graph.with_dids, player.with_player_id) live in their own module so the global vocabulary stays small.

Endpoint modules

Decoding Dynamic responses

Common views (Profile, Artist, Album, Song, Scrobble, Stats, Listener, Shout, ApiKey) are typed in rocksky/types. Inline anonymous shapes (e.g. feed search) are returned as Dynamic so you can decode on your terms:

Error handling

Types

Most public model types alias the lexicon-derived shapes in rocksky/generated/types, mirroring every lex *View* / *Record / *Input / *Output / *Params shape from the Rocksky lexicons. ApiKey and Shout are hand-written because they carry fields the lexicon does not yet declare. Regenerate with bun run lexgen:types at the repo root.

License

MIT © Tsiry Sandratraina. Source: sdk/gleam.