Tidlers
A Rust library for interacting with the TIDAL music streaming API.
Features
- OAuth 2.0 authentication
- Access token management and refresh
- Support for all TIDAL audio quality levels (Low, High, Lossless, HiRes)
- DASH manifest parsing for HiRes audio streaming
- API coverage:
- Track information and playback
- Album and playlist management
- Artist information
- User profile and subscription details
- Mixes and recommendations
- Session persistence for seamless re-authentication
- Type-safe API with serde-based deserialization
Projects using Tidlers
Tidlers is still very WIP, but here is my project that uses it:
- yadal - Command-line downloader with parallel downloads and all quality support
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Or use the git version for the latest features:
[]
= { = "https://codeberg.org/tomkoid/tidlers.git" }
Quick Start
use ;
async
Audio Quality Support
Tidlers supports all TIDAL audio quality tiers:
- Low: 96 kbps AAC
- High: 320 kbps AAC
- Lossless: 44.1 KHz FLAC (CD quality)
- HiRes: 192 KHz FLAC (High-Res)
HiRes audio uses DASH (Dynamic Adaptive Streaming over HTTP) manifests, which are automatically parsed by the library.
Session Persistence
Save and restore sessions to avoid re-authentication:
// Save session
let session_json = client.get_json;
write?;
// Load session
let session_data = read_to_string?;
let mut client = from_serialized?;
// Refresh token if needed
client.refresh_access_token.await?;
API Examples
Get Track Information
let track = client.get_track.await?;
println!;
println!;
println!;
Get Album Details
let album = client.get_album.await?;
// Takes in the album id with optional limit and offset for pagination
let items = client.get_album_items.await?;
Get Playlist
let playlist = client.get_playlist.await?;
// Takes in the playlist uuid with optional limit and offset for pagination
let items = client.get_playlist_items.await?;
Get Track Mixes (Recommendations)
let mix = client.get_track_mix.await?;
Check Subscription
let subscription = client.subscription.await?;
println!;
DASH Manifest Support
For HiRes audio, TIDAL uses DASH streaming. Tidlers parses these manifests automatically:
let playback_info = client.get_track_postpaywall_playback_info.await?;
match &playback_info.manifest_parsed
Examples
The repository includes several examples demonstrating different use cases:
testing_client
Basic example showing authentication, API calls, and data retrieval:
This example is also where I test new features during development.
hires_streamer
Complete audio streaming example with playback support:
Error Handling
The library uses the TidalError enum for error handling:
use TidalError;
match client.get_track.await
Requirements
- Rust 2024 edition
- TIDAL account with active subscription
- Network connection for API access (obviously)
Dependencies
Core dependencies:
reqwest- HTTP clientserde/serde_json- Serializationtokio- Async runtimebase64- Base64 encoding/decodingquick-xml- XML parsing for DASH manifeststhiserror- Error handling
Development
Build the library:
Run tests:
Run an example:
Notes
- OAuth device code flow requires user interaction via browser
- DASH segments for HiRes audio are MP4 fragments that need to be combined
- Rate limiting is not implemented; use responsibly
- Some parts of code and documentation are written using AI
License
This project is for educational and personal use. Ensure compliance with TIDAL's Terms of Service.
Disclaimer
This is an unofficial library and is not affiliated with or endorsed by TIDAL. Use at your own risk.