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()  # defaults to https://api.rocksky.app
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.2.tar.gz (61.2 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.2-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rocksky-0.4.2.tar.gz
  • Upload date:
  • Size: 61.2 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.2.tar.gz
Algorithm Hash digest
SHA256 c2bb942673e84b1f5f038b8f737f963420c06b5d68cac49713a332e256dc58c8
MD5 5fb9e04db9c86381c5421bfae2c21c62
BLAKE2b-256 8412d6c31fb645304be5fca482483c321cbdf78cf4e292d91c5c05e8e572a64c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rocksky-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 21.4 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9cc5ce6202ce2981d7f22d196fee6d96062795dcfdf692202b01b3381a47e5a2
MD5 cc83a268380510eb3aa6c8b6dd543c82
BLAKE2b-256 15c2da48cd444b74c7b72b81141cfc7ac9de481c43b518eb84aeb51e9c20e9c6

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