Core HTTP client for the Rocksky XRPC API.
A client is just a map. You build one with client, optionally thread
with-token / with-base-url / with-headers to extend it, and pass
it as the first argument to every endpoint function in
rocksky.actor, rocksky.album, etc.
Two low-level helpers — query and procedure — back every endpoint
fn. They translate XRPC's GET/POST split into clj-http calls and
return the parsed JSON body. On non-2xx responses they throw
ex-info with :status, :body, and :nsid in the ex-data.
Core HTTP client for the Rocksky XRPC API. A client is just a map. You build one with `client`, optionally thread `with-token` / `with-base-url` / `with-headers` to extend it, and pass it as the first argument to every endpoint function in `rocksky.actor`, `rocksky.album`, etc. Two low-level helpers — `query` and `procedure` — back every endpoint fn. They translate XRPC's GET/POST split into `clj-http` calls and return the parsed JSON body. On non-2xx responses they throw `ex-info` with `:status`, `:body`, and `:nsid` in the ex-data.
(client)(client {:keys [base-url token headers timeout-ms http-fn]
:or {base-url default-base-url headers {} timeout-ms 30000}})Build a Rocksky client.
Options: :base-url Base URL of the Rocksky API. Defaults to https://api.rocksky.app. :token Bearer token (JWT) for authenticated endpoints. Optional. :headers Extra default headers (map). Optional. :timeout-ms Per-request timeout in ms. Defaults to 30000. :http-fn Override the HTTP fn (takes a clj-http request map). Useful for tests.
Build a Rocksky client. Options: :base-url Base URL of the Rocksky API. Defaults to https://api.rocksky.app. :token Bearer token (JWT) for authenticated endpoints. Optional. :headers Extra default headers (map). Optional. :timeout-ms Per-request timeout in ms. Defaults to 30000. :http-fn Override the HTTP fn (takes a clj-http request map). Useful for tests.
(procedure c nsid)(procedure c nsid body)(procedure c nsid body params)Call an XRPC procedure (POST /xrpc/<nsid>).
Optional params map is sent as query string. Optional body map is
sent as a JSON request body. Returns the parsed JSON body.
Call an XRPC procedure (POST /xrpc/<nsid>). Optional `params` map is sent as query string. Optional `body` map is sent as a JSON request body. Returns the parsed JSON body.
(query c nsid)(query c nsid params)Call an XRPC query (GET /xrpc/<nsid>).
params is a map of query string parameters. nil values are dropped;
sequential values are repeated. Returns the parsed JSON body.
Call an XRPC query (GET /xrpc/<nsid>). `params` is a map of query string parameters. nil values are dropped; sequential values are repeated. Returns the parsed JSON body.
(with-base-url c base-url)Return a new client with a different base-url.
Return a new client with a different `base-url`.
(with-headers c headers)Return a new client with extra default headers merged in.
Return a new client with extra default `headers` merged in.
(with-token c token)Return a new client with token set as the Bearer credential.
Return a new client with `token` set as the Bearer credential.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |