Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/0xf4b1/tidal-kt
Tidal API client library for Kotlin
https://github.com/0xf4b1/tidal-kt
api client kotlin library tidal
Last synced: 15 days ago
JSON representation
Tidal API client library for Kotlin
- Host: GitHub
- URL: https://github.com/0xf4b1/tidal-kt
- Owner: 0xf4b1
- License: gpl-3.0
- Created: 2023-08-09T22:20:40.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-12-22T23:27:56.000Z (11 months ago)
- Last Synced: 2024-10-11T00:57:01.928Z (about 1 month ago)
- Topics: api, client, kotlin, library, tidal
- Language: Kotlin
- Homepage:
- Size: 87.9 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tidal-kt
Tidal API client library for Kotlin## Building
`./gradlew jar`
## Usage
### Session
```kotlin
val api = TidalApi(TidalApi.Session(, ::callback))// Callback to let you save session parameters
private fun callback(session: TidalApi.Session) {
session.userId
session.countryCode
session.accessToken
session.refreshToken
}// Start new device auth
val verificationUriComplete = api.auth()// Let the user visit verificationUriComplete and finish auth and
// periodically check if its completed
if (api.getAccessToken()) {
println("Auth complete")
}// If you have a stored session, you can restore it without starting new auth
api.session.setAuth(, , , )
```### Tracks
```kotlin
private fun printTracks(tracks: List) {
tracks.forEach { println("id: ${it.id}, artist: ${it.artist}, title: ${it.title}, duration: ${it.duration}, artwork: ${it.artwork}, url: ${it.url}, liked: ${it.liked}") }
}// Get tracks saved by the user
// You can call this function multiple times to get next results by passing false.
// If you want to refresh and get results from the beginning, you can reset by passing true.
val tracks = api.getTracks(false /* reset? */)
printTracks(tracks)
```### Artists
```kotlin
private fun printArtists(artists: List) {
artists.forEach { println("id: ${it.id}, name: ${it.name}, artwork: ${it.artwork}, url: ${it.url}") }
}// Get artists followed by the user
val artists = api.getArtists(false /* reset? */)
printArtists(first)// Get tracks from the an artist id
val tracks = api.getArtist(artists[0].id, false /* reset? */)
printTracks(tracks)
```### Mixes
```kotlin
// Get mixes
val tracks = api.getMix(Endpoints.Mixes.MIX_DAILY_DISCOVERY, false /* reset? */)
printTracks(tracks)
```### Search
```kotlin
// Search for tracks
val tracks = api.query("Solee", false /* reset? */)
printTracks(tracks)
```### Stream
```kotlin
// Get stream url for track id
val stream = api.getStreamUrl(tracks[0].id)
println("stream: $stream")
```