{"id":15673503,"url":"https://github.com/lmammino/lastfm","last_synced_at":"2025-07-28T12:10:09.555Z","repository":{"id":138311175,"uuid":"599279720","full_name":"lmammino/lastfm","owner":"lmammino","description":"An async client to fetch your Last.fm listening history or the track you are currently playing","archived":false,"fork":false,"pushed_at":"2024-05-05T18:12:36.000Z","size":134,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-26T16:04:37.949Z","etag":null,"topics":["client","history","http","last-fm","lastfm","lastfm-api","nowplaying","rust","scrobble","scrobbles","scrobbling"],"latest_commit_sha":null,"homepage":"https://loige.co","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lmammino.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2023-02-08T20:18:50.000Z","updated_at":"2024-05-05T18:12:07.000Z","dependencies_parsed_at":"2024-10-23T16:45:42.004Z","dependency_job_id":"57dd1eca-7597-4f81-99de-e4b08dafd733","html_url":"https://github.com/lmammino/lastfm","commit_stats":{"total_commits":38,"total_committers":3,"mean_commits":"12.666666666666666","dds":0.07894736842105265,"last_synced_commit":"35e658b4a409195ab1b64f79f8047a797bbc908b"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/lmammino/lastfm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmammino%2Flastfm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmammino%2Flastfm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmammino%2Flastfm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmammino%2Flastfm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lmammino","download_url":"https://codeload.github.com/lmammino/lastfm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmammino%2Flastfm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262099718,"owners_count":23258668,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["client","history","http","last-fm","lastfm","lastfm-api","nowplaying","rust","scrobble","scrobbles","scrobbling"],"created_at":"2024-10-03T15:40:58.874Z","updated_at":"2025-06-26T16:09:18.914Z","avatar_url":"https://github.com/lmammino.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lastfm\n\n[![Build Status](https://github.com/lmammino/lastfm/actions/workflows/rust.yml/badge.svg)](https://github.com/lmammino/lastfm/actions/workflows/rust.yml)\n[![Crates.io](https://img.shields.io/crates/v/lastfm.svg)](https://crates.io/crates/lastfm)\n[![docs.rs](https://docs.rs/lastfm/badge.svg)](https://docs.rs/lastfm)\n\n\n\n\u003c!-- cargo-sync-readme start --\u003e\n\n`lastfm` is an async Rust client to fetch your [Last.fm](https://last.fm) listening history or the track you are currently playing\n\n## Installation\n\nAdd the following to your `Cargo.toml`:\n\n```toml\n[dependencies]\nlastfm = \"*\"\n```\n\nReplace the `*` with the actual version you want to use.\n\n\nAlternatively you can run:\n\n```bash\ncargo add lastfm\n````\n\n## Usage\n\nTo use this library you will need a Last.fm account and an API key.\nYou can get one by [registering an application](https://www.last.fm/api/account/create).\nIf you have already registered an application, you can find your API key in the [API settings](https://www.last.fm/api/accounts).\n\n### Create a new client\n\nIf you have your API key exposed through the `LASTFM_API_KEY` environment variable, you can use the `from_env` method:\n\n```rust,no_run\nlet client = Client::\u003cString, \u0026str\u003e::from_env(\"YOUR_USERNAME\");\n```\n\nNote: this method will panic if `LASTFM_API_KEY` is not set.\n\nAlternatively, you can use `try_from_env` which will return a `Result`.\n\n```rust,no_run\nlet maybe_client = Client::\u003cString, \u0026str\u003e::try_from_env(\"YOUR_USERNAME\");\nmatch maybe_client {\n  Ok(client) =\u003e {\n    // do something with the client\n  }\n  Err(e) =\u003e {\n    // handle error\n  }\n}\n```\n\nFinally, for more advanced configurations you can use a `Client::builder()`:\n\n```rust\nlet client = Client::builder().api_key(\"YOUR_API_KEY\").username(\"YOUR_USERNAME\").build();\n```\n\n### Fetch the track you are currently playing\n\n```rust,no_run\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n  let client = Client::builder().api_key(\"YOUR_API_KEY\").username(\"YOUR_USERNAME\").build();\n  let now_playing = client.now_playing().await?;\n  if let Some(track) = now_playing {\n    println!(\"Now playing: {} - {}\", track.artist.name, track.name);\n  }\n\n  Ok(())\n}\n```\n\n### Fetch your listening history\n\n**Note**: You will need the `futures-util` crate to use the `Stream` returned by `all_tracks`.\n\n\n```rust,no_run\nuse futures_util::pin_mut;\nuse futures_util::stream::StreamExt;\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n  let client = Client::builder().api_key(\"YOUR_API_KEY\").username(\"YOUR_USERNAME\").build();\n  let tracks = client.all_tracks().await?;\n  println!(\"Total tracks: {}\", tracks.total_tracks);\n\n   let recent_tracks = tracks.into_stream();\n   pin_mut!(recent_tracks); // needed for iteration\n   while let Some(track) = recent_tracks.next().await {\n       match track {\n           Ok(track) =\u003e {\n               println!(\n                   \"{}: {} - {}\",\n                   track.date.to_rfc2822(),\n                   track.artist.name,\n                   track.name\n               );\n           }\n           Err(e) =\u003e {\n               println!(\"Error fetching data: {:?}\", e);\n           }\n       }\n   }\n   Ok(())\n}\n```\n\n\u003c!-- cargo-sync-readme end --\u003e\n\n## Examples\n\nThis package provides some usage examples in the [`examples`](/examples/) folder.\n\nYou will need an API key to run the examples so you will need to:\n\n- copy `.env~sample` into `.env`\n- add your last.fm API Key in there\n- run a give example. E.g.: `cargo run --example fetch_all`\n\n\n## Other implementations\n\nThis project is a port of something I have already done in JavaScript (Node.js). Check out [`lmammino/scrobbles`](https://github.com/lmammino/scrobbles) if you are curious.\n\n\n## Contributing\n\nEveryone is very welcome to contribute to this project.\nYou can contribute just by submitting bugs or suggesting improvements by\n[opening an issue on GitHub](https://github.com/lmammino/lastfm/issues).\n\n\n## License\n\nLicensed under [MIT License](LICENSE). © Luciano Mammino.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flmammino%2Flastfm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flmammino%2Flastfm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flmammino%2Flastfm/lists"}