Lastfm-rust: Rust library for accessing the Last.fm API.
Overview
lastfm-rust is a Rust library that provides user for interacting with the Last.fm API.
You can view Last.fm's official API documentation here.
Install
Run this command in your terminal to add the latest version of lastfm-rust.
Usage
Before you begin, make sure you have the following environment variables set up for authentication:
API_KEYAPI_SECRETSK(session key)only if you already have one
These keys are required for making API requests.
Example Setup:
- Set Up Environment Variables:
You can create a .env file in your project directory with the following content:
API_KEY=your_api_key
API_SECRET=your_api_secret
SK=your_session_key
- Usage Example:
Here is a simple example of how to use the lastfm-rust library to interact with the API:
use dotenv;
use Lastfm;
use Error;
async
Example: Get Session Key
Here’s how you can get session key using the auth() method:
let lastfm = builder
.api_key
.api_secret
.build?;
// Request token
let response = lastfm.auth.get_token.send.await?;
let token = match response ;
// Authorize the token and get session key
lastfm.auth.pls_authorize;
let response = lastfm.auth.get_session.token.send.await?;
println!;
Features
- Album
- Auth
- Artist
- Chart
- Geo
- Library
- Tag
- Track
- User
scrobblings
Note: If you're looking for a good scrobbling functionality, please use rustfm-scrobble or any other library for now.
Example Requests
let album_info = lastfm
.album
.get_info
.artist
.album
.send
.await?;
let tags = lastfm
.album
.get_tags
.artist
.album
.send
.await?;
let remove_response = lastfm
.album
.remove_tags
.artist
.album
.tags
.send
.await?;
More examples can be found in the examples folder.
TODO
- A proper Models instead of returning
serde_json::Value - Proper testing of each endpoints.
- Refactor using traits and macros.
- Detailed error handling
- A proper Logging
Contributing
Contributions are welcome! For any bug reports/feature requests, feel free to open an issue or submit a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details.