rocksky — Rust SDK
Async Rust SDK for the Rocksky XRPC API.
- Async-first — built on
tokio+reqwest - Typed — strongly typed
serdemodels, snake_case API - Builder-friendly — every list/paginated endpoint and every multi-field
request is a fluent builder (
.limit(10).offset(0).send().await) - Idiomatic — namespaced accessors:
client.actor(),client.scrobble(), … - Escape hatch —
client.call()/client.procedure()for any XRPC method not yet wrapped - Pipe-friendly — every response round-trips through
serde_json, so you can stream results straight tostdoutor shell pipelines (jq, etc.) - Compiles on Rust 1.75+
Install
[]
= "0.1"
= { = "1", = ["macros", "rt-multi-thread"] }
Pin TLS backend if you don't want rustls (the default):
= { = "0.1", = false, = ["native-tls"] }
Quickstart
use Client;
async
Authenticating
Pass a bearer token at construction time:
let client = builder
.token
.build;
…or change it later:
client.set_token.await;
Self-hosting / custom base URL
Default is https://api.rocksky.app:
let client = builder
.base_url
.token
.timeout
.build;
Builders everywhere
The fluent style maps every optional field to a chainable method, then calls
.send() to dispatch:
// List builder
let songs = client.actor.get_songs
.limit
.offset
.start_date
.send.await?;
// Mutation builder (only the required args are positional)
let _ = client.scrobble.create
.album
.duration
.year
.send.await?;
// Charts
let top = client.charts.top_tracks
.limit
.send.await?;
Resources
| Namespace | Accessor | Methods (selected) |
|---|---|---|
app.rocksky.actor |
client.actor() |
get_profile, get_profile_me, get_albums, get_artists, get_songs, get_scrobbles, get_loved_songs, get_playlists, get_neighbours, get_compatibility |
app.rocksky.album |
client.album() |
get, list, get_tracks |
app.rocksky.artist |
client.artist() |
get, list, get_albums, get_tracks, get_listeners, get_recent_listeners |
app.rocksky.song |
client.song() |
get, get_by_mbid, get_by_isrc, get_by_spotify_id, list, match_song, get_recent_listeners, create |
app.rocksky.scrobble |
client.scrobble() |
get, list, create |
app.rocksky.charts |
client.charts() |
top_tracks, top_artists, scrobbles_chart |
app.rocksky.feed |
client.feed() |
get, search, stories, recommendations, artist_recommendations, album_recommendations, get_generator, list_generators |
app.rocksky.graph |
client.graph() |
follow, unfollow, get_followers, get_follows, get_known_followers |
app.rocksky.shout |
client.shout() |
create, reply, remove, report, for_profile, for_album, for_artist, for_track, replies |
app.rocksky.like |
client.like() |
like_song, dislike_song, like_shout, dislike_shout |
app.rocksky.playlist |
client.playlist() |
get, list, create, remove, start, insert_files, insert_directory |
app.rocksky.player |
client.player() |
currently_playing, queue, play, pause, next, previous, seek, play_file, play_directory, add_items_to_queue |
app.rocksky.spotify |
client.spotify() |
currently_playing, play, pause, next, previous, seek |
app.rocksky.apikey |
client.apikey() |
list, create, update, remove |
app.rocksky.stats |
client.stats() |
get, wrapped |
app.rocksky.mirror |
client.mirror() |
list_sources, put_source |
app.rocksky.dropbox |
client.dropbox() |
list_files, metadata, temporary_link, download_file |
app.rocksky.googledrive |
client.googledrive() |
list_files, get_file, download_file |
For methods that aren't typed yet, drop down to the generic escape hatch:
let raw: Value =
client.call.await?;
Errors
All fallible methods return Result<T, rocksky::Error>. The Error enum
carries the full server response when the API returns a non-2xx:
use Error;
match client.song.get.await
Convenience predicates: is_unauthorized(), is_forbidden(),
is_not_found(), is_rate_limited(), is_client_error(), is_server_error().
Pipe-friendly CLI use
The included search example streams hits as one JSON object per line —
drop-in for jq:
|
Examples
Runnable examples live in examples/:
examples/quickstart.rs— fetch a profile and recent scrobblesexamples/scrobble.rs— submit a scrobble (needsROCKSKY_TOKEN)examples/wrapped.rs— print a user's year-in-review JSONexamples/search.rs— search + line-delimited JSON outputexamples/follow_feed.rs— page through the follow-graph feed
Run with:
Testing your own code against the SDK
Provide your own reqwest::Client and point the SDK at a mock server.
The SDK's own test suite uses wiremock:
use ;
use ;
async
Development
License
MIT © Tsiry Sandratraina.