Skip to main content

Python SDK for Rocksky — native bindings to the shared Rust core

Project description

rocksky — Python SDK

Python bindings to the shared Rocksky Rust core (rocksky-sdk) via UniFFI: AppView reads, AT Protocol PDS writes (scrobble fan-out, like, follow, shout, now-playing), a local duplicate-prevention index, and the identity hashes — the same engine behind every Rocksky SDK (Ruby, Kotlin, Clojure, Erlang/Elixir/Gleam).

Install

pip install rocksky        # or: uv add rocksky

The wheel is pure-Python; the ~14 MB native library is fetched from the GitHub release on first import and cached (checksum-verified). For a local checkout, build it once:

./build-core.sh

Quickstart

from rocksky import AppView, Agent, ScrobbleInput, song_hash

# Reads — unauthenticated. Pass a base URL to override https://api.rocksky.app.
av = AppView(None)
print(av.global_stats().scrobbles)
for t in av.top_tracks(10, 0):
    print(t.artist, "—", t.title)

# Writes — log in once (session persisted at the given path).
agent = Agent.login_password("session.json", "alice.bsky.social", "app-password", None, None)
out = agent.scrobble(ScrobbleInput(
    title="Chaser", artist="Calibro 35",
    album="Jazzploitation", album_artist="Calibro 35", duration_ms=182320,
))
print(out.scrobble_uri)   # also artist_uri / album_uri / song_uri

API

Reads — AppView(base=None)

profile(actor), scrobbles(actor, limit, offset), songs(actor, limit, offset), top_tracks(limit, offset), top_artists(limit, offset), global_stats(). Pass a base URL to AppView(...) to target a custom AppView.

Writes — Agent

Agent.login_password(session_path, identifier, password, appview=None, dedup_path=None) returns an agent. Then:

  • scrobble(ScrobbleInput)ScrobbleResult — writes artist + album + song + scrobble, skipping any that already exist (with a dedup store).
  • create_song(SongInput), create_album(AlbumInput), create_artist(ArtistInput)
  • like(uri, cid), unlike(uri), follow(did), unfollow(did)
  • shout(subject_uri, subject_cid, message), reply_shout(...)
  • set_now_playing(NowPlayingInput), clear_now_playing()
  • refresh_session(), did(), profile()
  • sync_repo() — mirror the repo into the local dedup index (needs dedup_path)

Identity hashes

song_hash(title, artist, album), album_hash(album, album_artist), artist_hash(album_artist) — lowercase-hex SHA-256, identical to the server and every other Rocksky SDK.

Example

python examples/native_core.py

License

MIT.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rocksky-0.4.1.tar.gz (61.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rocksky-0.4.1-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file rocksky-0.4.1.tar.gz.

File metadata

  • Download URL: rocksky-0.4.1.tar.gz
  • Upload date:
  • Size: 61.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for rocksky-0.4.1.tar.gz
Algorithm Hash digest
SHA256 ca02f240947608e185c8efc42d8d506ec09a26a28152d5b220500013a7b0bdfd
MD5 91f59b8cac0a286c307533267f2c4928
BLAKE2b-256 a3ef15118092cc237bd38cddaef40bd23803c4fe430db5d4979dbd6022c6f299

See more details on using hashes here.

File details

Details for the file rocksky-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: rocksky-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for rocksky-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3751da0e6a9d887a77cbe406faf9ac3ffff2943c97742eeebde022ad99d3310e
MD5 be310fe4fd760beb849573ce09f1e247
BLAKE2b-256 0337473ad1854447f06224c6bf424366f47111b3eec1a12f1eac382553203214

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page