{"id":35163942,"url":"https://github.com/ducks/last-fm-rs","last_synced_at":"2026-05-17T21:36:42.174Z","repository":{"id":327656936,"uuid":"1109395791","full_name":"ducks/last-fm-rs","owner":"ducks","description":"A Rust based client API for Last.fm","archived":false,"fork":false,"pushed_at":"2026-01-20T18:13:50.000Z","size":71,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-14T00:07:42.470Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ducks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-03T18:40:46.000Z","updated_at":"2026-01-20T18:13:53.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ducks/last-fm-rs","commit_stats":null,"previous_names":["ducks/last-fm-rs"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/ducks/last-fm-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ducks%2Flast-fm-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ducks%2Flast-fm-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ducks%2Flast-fm-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ducks%2Flast-fm-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ducks","download_url":"https://codeload.github.com/ducks/last-fm-rs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ducks%2Flast-fm-rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33028520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-28T19:03:43.193Z","updated_at":"2026-05-17T21:36:42.130Z","avatar_url":"https://github.com/ducks.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# last-fm-rs\n\nRust client library for the Last.fm API, focused on desktop application scrobbling.\n\nSupports both Last.fm's official API and custom token-based scrobbling servers.\n\n## Features\n\n- **Last.fm Mode:**\n  - Desktop authentication flow\n  - API key + secret with session key authentication\n  - Full Last.fm API signature generation\n\n- **Token Mode:**\n  - Simple bearer token authentication\n  - Custom base URL for self-hosted servers\n  - JSON request/response bodies\n\n- **Common Features:**\n  - \"Now Playing\" updates\n  - Scrobble submission (single or batch up to 50)\n  - Fully async with tokio\n  - Type-safe API\n\n## Installation\n\n```toml\n[dependencies]\nlast-fm-rs = \"0.1\"\n```\n\n## Usage\n\n### Last.fm Mode\n\n#### Authentication Flow\n\n```rust\nuse last_fm_rs::Client;\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n  // Create client with your API credentials\n  let client = Client::new(\"your_api_key\", \"your_api_secret\");\n\n  // Step 1: Get authentication token\n  let token = client.get_token().await?;\n\n  // Step 2: Direct user to authorize\n  let auth_url = client.get_auth_url(\u0026token)?;\n  println!(\"Please authorize at: {}\", auth_url);\n  println!(\"Press Enter when done...\");\n\n  let mut input = String::new();\n  std::io::stdin().read_line(\u0026mut input)?;\n\n  // Step 3: Exchange token for session key\n  let session = client.get_session(\u0026token).await?;\n  println!(\"Session key: {}\", session.key);\n  println!(\"Username: {}\", session.name);\n\n  // Save session.key for future use\n  Ok(())\n}\n```\n\n#### Scrobbling\n\n```rust\nuse last_fm_rs::{Client, NowPlaying, Scrobble};\nuse std::time::{SystemTime, UNIX_EPOCH};\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n  let client = Client::new(\"api_key\", \"secret\")\n    .with_session_key(\"saved_session_key\");\n\n  // Update \"Now Playing\"\n  let now_playing = NowPlaying::new(\"Kendrick Lamar\", \"Wesley's Theory\")\n    .with_album(\"To Pimp a Butterfly\")\n    .with_duration(287);\n\n  client.update_now_playing(\u0026now_playing).await?;\n\n  // Submit scrobble after track finishes\n  let timestamp = SystemTime::now()\n    .duration_since(UNIX_EPOCH)?\n    .as_secs();\n\n  let scrobble = Scrobble::new(\"Kendrick Lamar\", \"Wesley's Theory\", timestamp)\n    .with_album(\"To Pimp a Butterfly\")\n    .with_duration(287);\n\n  let response = client.scrobble(\u0026[scrobble]).await?;\n  println!(\"Scrobbled: {} accepted, {} ignored\",\n    response.scrobbles.attr.accepted,\n    response.scrobbles.attr.ignored\n  );\n\n  Ok(())\n}\n```\n\n#### Batch Scrobbling\n\n```rust\nlet scrobbles = vec![\n  Scrobble::new(\"Artist 1\", \"Track 1\", timestamp1),\n  Scrobble::new(\"Artist 2\", \"Track 2\", timestamp2),\n  // ... up to 50 scrobbles\n];\n\nlet response = client.scrobble(\u0026scrobbles).await?;\n```\n\n### Token Mode\n\nFor custom scrobbling servers that use bearer token authentication:\n\n```rust\nuse last_fm_rs::{Client, NowPlaying, Scrobble};\nuse std::time::{SystemTime, UNIX_EPOCH};\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n  // Create client with token-based auth\n  let client = Client::with_token(\n    \"https://scrob.example.com/api/\",\n    \"your-secret-token\"\n  )?;\n\n  // Update \"Now Playing\"\n  let now_playing = NowPlaying::new(\"Kendrick Lamar\", \"Wesley's Theory\")\n    .with_album(\"To Pimp a Butterfly\")\n    .with_duration(287);\n\n  client.update_now_playing(\u0026now_playing).await?;\n\n  // Submit scrobble\n  let timestamp = SystemTime::now()\n    .duration_since(UNIX_EPOCH)?\n    .as_secs();\n\n  let scrobble = Scrobble::new(\"Kendrick Lamar\", \"Wesley's Theory\", timestamp)\n    .with_album(\"To Pimp a Butterfly\")\n    .with_duration(287);\n\n  let response = client.scrobble(\u0026[scrobble]).await?;\n  println!(\"Scrobbled: {} accepted\", response.scrobbles.attr.accepted);\n\n  Ok(())\n}\n```\n\nToken mode sends:\n- `POST {base_url}/now` for now playing updates\n- `POST {base_url}/scrob` for scrobbles\n- `Authorization: Bearer {token}` header\n- JSON request bodies\n\n## API Credentials\n\n**Last.fm Mode:**\nGet your API key and secret from: https://www.last.fm/api/account/create\n\n**Token Mode:**\nObtain your token from your self-hosted scrobbling server.\n\n## License\n\nMIT OR Apache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fducks%2Flast-fm-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fducks%2Flast-fm-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fducks%2Flast-fm-rs/lists"}