Spotify.NET/SpotifyAPI.Docs/docs/web/library.md

205 lines
6.1 KiB
Markdown
Raw Normal View History

2019-08-16 23:40:04 +01:00
# Library
## SaveTracks
2016-08-20 11:49:09 +01:00
> Save one or more tracks to the current users “Your Music” library.
2019-08-16 23:40:04 +01:00
**Parameters**
2016-08-20 11:49:09 +01:00
|Name|Description|Example|
|--------------|-------------------------|-------------------------|
|ids| A list of the Spotify IDs | `new List<String> { "3Hvu1pq89D4R0lyPBoujSv" }`
2019-08-16 23:40:04 +01:00
Returns a `ErrorResponse` which just contains a possible error. (`response.HasError()` and `response.Error`)
2016-08-20 11:49:09 +01:00
2019-08-16 23:40:04 +01:00
**Usage**
```csharp
2016-08-20 11:49:09 +01:00
ErrorResponse response = _spotify.SaveTracks(new List<string> { "3Hvu1pq89D4R0lyPBoujSv" });
if(!response.HasError())
Console.WriteLine("success");
```
---
2019-08-16 23:40:04 +01:00
## SaveTrack
2016-08-20 11:49:09 +01:00
> Save one track to the current users “Your Music” library.
2019-08-16 23:40:04 +01:00
**Parameters**
2016-08-20 11:49:09 +01:00
|Name|Description|Example|
|--------------|-------------------------|-------------------------|
|id| A Spotify ID | `"3Hvu1pq89D4R0lyPBoujSv"`
2019-08-16 23:40:04 +01:00
Returns a `ErrorResponse` which just contains a possible error. (`response.HasError()` and `response.Error`)
2016-08-20 11:49:09 +01:00
2019-08-16 23:40:04 +01:00
**Usage**
```csharp
2016-08-20 11:49:09 +01:00
ErrorResponse response = _spotify.SaveTrack("3Hvu1pq89D4R0lyPBoujSv");
if(!response.HasError())
Console.WriteLine("success");
```
---
2019-08-16 23:40:04 +01:00
## GetSavedTracks
2016-08-20 11:49:09 +01:00
> Get a list of the songs saved in the current Spotify users “Your Music” library.
2019-08-16 23:40:04 +01:00
**Parameters**
2016-08-20 11:49:09 +01:00
|Name|Description|Example|
|--------------|-------------------------|-------------------------|
|[limit]| The maximum number of objects to return. Default: 20. Minimum: 1. Maximum: 50. | `20`
|[offset]| The index of the first object to return. Default: 0 (i.e., the first object) | `0`
|[market]| An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. | `DE`
2019-08-16 23:40:04 +01:00
Returns a `Paging<SavedTrack>**, **SavedTrack` contains 2 properties, `DateTime AddedAt` and `FullTrack Track`
2016-08-20 11:49:09 +01:00
2019-08-16 23:40:04 +01:00
**Usage**
```csharp
2016-08-20 11:49:09 +01:00
Paging<SavedTrack> savedTracks = _spotify.GetSavedTracks();
savedTracks.Items.ForEach(track => Console.WriteLine(track.Track.Name));
```
---
2019-08-16 23:40:04 +01:00
## RemoveSavedTracks
2016-08-20 11:49:09 +01:00
> Remove one or more tracks from the current users “Your Music” library.
2019-08-16 23:40:04 +01:00
**Parameters**
2016-08-20 11:49:09 +01:00
|Name|Description|Example|
|--------------|-------------------------|-------------------------|
|ids| A list of the Spotify IDs. | `new List<String> { "3Hvu1pq89D4R0lyPBoujSv" }`
2019-08-16 23:40:04 +01:00
Returns a `ErrorResponse` which just contains a possible error. (`response.HasError()` and `response.Error`)
2016-08-20 11:49:09 +01:00
2019-08-16 23:40:04 +01:00
**Usage**
```csharp
2016-08-20 11:49:09 +01:00
ErrorResponse response = _spotify.RemoveSavedTracks(new List<string> { "3Hvu1pq89D4R0lyPBoujSv" });
if(!response.HasError())
Console.WriteLine("success");
```
---
2019-08-16 23:40:04 +01:00
## CheckSavedTracks
2016-08-20 11:49:09 +01:00
> Check if one or more tracks is already saved in the current Spotify users “Your Music” library.
2019-08-16 23:40:04 +01:00
**Parameters**
2016-08-20 11:49:09 +01:00
|Name|Description|Example|
|--------------|-------------------------|-------------------------|
|ids| A list of the Spotify IDs. | `new List<String> { "3Hvu1pq89D4R0lyPBoujSv" }`
2019-08-16 23:40:04 +01:00
Returns a `ListResponse<bool>` which contains a property, `List<bool> List`
2016-08-20 11:49:09 +01:00
2019-08-16 23:40:04 +01:00
**Usage**
```csharp
2016-08-20 11:49:09 +01:00
ListResponse<bool> tracksSaved = _spotify.CheckSavedTracks(new List<String> { "3Hvu1pq89D4R0lyPBoujSv" });
if(tracksSaved.List[0])
Console.WriteLine("The track is in your library!");
```
---
2019-08-16 23:40:04 +01:00
## SaveAlbums
2016-08-20 11:49:09 +01:00
> Save one or more albums to the current users “Your Music” library.
2019-08-16 23:40:04 +01:00
**Parameters**
2016-08-20 11:49:09 +01:00
|Name|Description|Example|
|--------------|-------------------------|-------------------------|
|ids| A list of the Spotify IDs | `new List<String> { "1cq06d0kTUnFmJHixz1RaF" }`
2019-08-16 23:40:04 +01:00
Returns a `ErrorResponse` which just contains a possible error. (`response.HasError()` and `response.Error`)
2016-08-20 11:49:09 +01:00
2019-08-16 23:40:04 +01:00
**Usage**
```csharp
2016-08-20 11:49:09 +01:00
ErrorResponse response = _spotify.SaveAlbums(new List<string> { "1cq06d0kTUnFmJHixz1RaF" });
if(!response.HasError())
Console.WriteLine("success");
```
---
2019-08-16 23:40:04 +01:00
## SaveAlbum
2016-08-20 11:49:09 +01:00
> Save one album to the current users “Your Music” library.
2019-08-16 23:40:04 +01:00
**Parameters**
2016-08-20 11:49:09 +01:00
|Name|Description|Example|
|--------------|-------------------------|-------------------------|
|id| A Spotify ID | `"1cq06d0kTUnFmJHixz1RaF"`
2019-08-16 23:40:04 +01:00
Returns a `ErrorResponse` which just contains a possible error. (`response.HasError()` and `response.Error`)
2016-08-20 11:49:09 +01:00
2019-08-16 23:40:04 +01:00
**Usage**
```csharp
2016-08-20 11:49:09 +01:00
ErrorResponse response = _spotify.SaveAlbum("1cq06d0kTUnFmJHixz1RaF");
if(!response.HasError())
Console.WriteLine("success");
```
---
2019-08-16 23:40:04 +01:00
## GetSavedAlbums
2016-08-20 11:49:09 +01:00
> Get a list of the albums saved in the current Spotify users “Your Music” library.
2019-08-16 23:40:04 +01:00
**Parameters**
2016-08-20 11:49:09 +01:00
|Name|Description|Example|
|--------------|-------------------------|-------------------------|
|[limit]| The maximum number of objects to return. Default: 20. Minimum: 1. Maximum: 50. | `20`
|[offset]| The index of the first object to return. Default: 0 (i.e., the first object) | `0`
|[market]| An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. | `DE`
Returns a `Paging<SavedAlbum>`, **SavedAlbum** contains 2 properties, `DateTime AddedAt` and `FullAlbum Album`
2019-08-16 23:40:04 +01:00
**Usage**
```csharp
2016-08-20 11:49:09 +01:00
Paging<SavedAlbum> savedAlbums = _spotify.GetSavedAlbums();
savedAlbums.Items.ForEach(album => Console.WriteLine(album.Album.Name));
```
---
2019-08-16 23:40:04 +01:00
## RemoveSavedAlbums
2016-08-20 11:49:09 +01:00
> Remove one or more albums from the current users “Your Music” library.
2019-08-16 23:40:04 +01:00
**Parameters**
2016-08-20 11:49:09 +01:00
|Name|Description|Example|
|--------------|-------------------------|-------------------------|
|ids| A list of the Spotify IDs. | `new List<String> { "1cq06d0kTUnFmJHixz1RaF" }`
2019-08-16 23:40:04 +01:00
Returns a `ErrorResponse` which just contains a possible error. (`response.HasError()` and `response.Error`)
2016-08-20 11:49:09 +01:00
2019-08-16 23:40:04 +01:00
**Usage**
```csharp
2016-08-20 11:49:09 +01:00
ErrorResponse response = _spotify.RemoveSavedAlbums(new List<string> { "1cq06d0kTUnFmJHixz1RaF" });
if(!response.HasError())
Console.WriteLine("success");
```
---
2019-08-16 23:40:04 +01:00
## CheckSavedAlbums
2016-08-20 11:49:09 +01:00
> Check if one or more albums is already saved in the current Spotify users “Your Music” library.
2019-08-16 23:40:04 +01:00
**Parameters**
2016-08-20 11:49:09 +01:00
|Name|Description|Example|
|--------------|-------------------------|-------------------------|
|ids| A list of the Spotify IDs. | `new List<String> { "1cq06d0kTUnFmJHixz1RaF" }`
2019-08-16 23:40:04 +01:00
Returns a `ListResponse<bool>` which contains a property, `List<bool> List`
2016-08-20 11:49:09 +01:00
2019-08-16 23:40:04 +01:00
**Usage**
```csharp
2016-08-20 11:49:09 +01:00
ListResponse<bool> albumsSaved = _spotify.CheckSavedAlbums(new List<String> { "1cq06d0kTUnFmJHixz1RaF" });
if(albumsSaved.List[0])
Console.WriteLine("The album is in your library!");
```
---