Tidalrs
A comprehensive Rust client library for the Tidal music streaming service API. This library provides async/await support, automatic token refresh, and a clean, type-safe interface for interacting with Tidal's music catalog and user data.
Features
- 🎵 Complete Music API: Access tracks, albums, artists, and playlists
- 🎧 Audio Streaming: Download and stream tracks in various quality levels
- 🔍 Advanced Search: Search across all content types with filtering
- 👤 User Management: Manage favorites, playlists, and user data
- 🔐 OAuth2 Authentication: Device flow authentication with automatic token refresh
- 🚀 Async/Await: Built on Tokio for high-performance async operations
- 🛡️ Type Safety: Comprehensive type definitions for all Tidal API responses
- 📱 Cross-Platform: Works on all platforms supported by Rust
Quick Start
Add this to your Cargo.toml
:
[]
= "0.1.0"
= { = "1.0", = ["full"] }
Basic Usage
use ;
async
Using Existing Authentication
If you already have authentication tokens:
use ;
let authz = new;
let client = new
.with_authz;
API Overview
Authentication
The library supports Tidal's OAuth2 device flow authentication:
// Start device authorization
let device_auth = client.device_authorization.await?;
// User visits the URL and enters the code
println!;
println!;
// Complete authorization
let authz_token = client.authorize.await?;
Searching
Search across all content types:
use ;
let mut query = new;
query.limit = Some;
query.search_types = Some;
let results = client.search.await?;
for artist in results.artists.items
for album in results.albums.items
Tracks
Get track information and stream audio:
// Get track details
let track = client.track.await?;
println!;
// Get streaming URL
let stream = client.track_stream.await?;
let audio_stream = stream.stream.await?;
// Add to favorites
client.add_favorite_track.await?;
Albums
Work with albums and their tracks:
// Get album information
let album = client.album.await?;
println!;
// Get album tracks
let tracks = client.album_tracks.await?;
for track in tracks.items
// Add album to favorites
client.add_favorite_album.await?;
Artists
Explore artist information and their albums:
// Get artist details
let artist = client.artist.await?;
println!;
// Get artist's albums
let albums = client.artist_albums.await?;
for album in albums.items
Playlists
Manage playlists and their contents:
// Create a new playlist
let playlist = client.create_playlist.await?;
println!;
// Add tracks to playlist
let track_ids = vec!;
client.add_tracks_to_playlist.await?;
// Get playlist tracks
let tracks = client.playlist_tracks.await?;
for track in tracks.items
// Remove a track from playlist
client.remove_track_from_playlist.await?;
User Favorites
Manage user's favorite content:
// Get favorite tracks
let favorite_tracks = client.favorite_tracks.await?;
for fav_track in favorite_tracks.items
// Get favorite albums
let favorite_albums = client.favorite_albums.await?;
for fav_album in favorite_albums.items
// Get favorite artists
let favorite_artists = client.favorite_artists.await?;
for fav_artist in favorite_artists.items
Audio Quality
The library supports all Tidal audio quality levels:
use AudioQuality;
// Available quality levels:
// - AudioQuality::Low
// - AudioQuality::High
// - AudioQuality::Lossless
// - AudioQuality::HiResLossless
let stream = client.track_stream.await?;
Configuration
Configure the client for different regions and locales:
let client = new
.with_country_code // United Kingdom
.with_locale // British English
.with_device_type;
Token Refresh
The client automatically handles token refresh, but you can also set up callbacks:
use Arc;
let client = new
.with_authz_refresh_callback;
Examples
Check the examples/
directory for complete working examples:
basic_search.rs
- Simple search functionalityplaylist_management.rs
- Creating and managing playlistsaudio_streaming.rs
- Streaming and playing audiofavorites_management.rs
- Managing user favorites
Requirements
- Rust 1.70+
- Tokio runtime
- Valid Tidal API client credentials
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Disclaimer
This library is not officially affiliated with Tidal. Use at your own risk and ensure compliance with Tidal's Terms of Service.