Spotify.NET/SpotifyAPI.Docs/versioned_docs/version-5.1.1/web/personalization.md

70 lines
2.8 KiB
Markdown
Raw Normal View History

2020-05-13 17:25:42 +01:00
---
id: personalization
title: Personalization
sidebar_label: Personalization
---
2019-08-16 23:40:04 +01:00
2018-01-15 22:32:21 +00:00
## GetUsersTopTracks
> Get the current users top tracks based on calculated affinity.
2019-08-16 23:40:04 +01:00
**Parameters**
2018-01-15 22:32:21 +00:00
|Name|Description|Example|
|--------------|-------------------------|-------------------------|
|[timeRange]| Over what time frame the affinities are compute. | `TimeRangeType.MediumTerm`
|[limit]| The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50. | `20`
|[offset]| The index of the first entity to return. Default: 0 (i.e., the first track). Use with limit to get the next set of entities. | `0`
Returns a [FullTrack](https://developer.spotify.com/web-api/object-model/#track-object-full) wrapped inside a [Paging-object](https://developer.spotify.com/web-api/object-model/#paging-object)
2019-08-16 23:40:04 +01:00
**Usage**
2018-01-15 22:32:21 +00:00
```
Paging<FullTrack> tracks = _spotify.GetUsersTopTracks();
tracks.Items.ForEach(item => Console.WriteLine(item.Name)); //Display all fetched Track-Names (max 20)
Console.WriteLine(tracks.Total.ToString()) //Display total album track count
```
---
## GetUsersTopArtists
> Get the current users top artists based on calculated affinity.
2019-08-16 23:40:04 +01:00
**Parameters**
2018-01-15 22:32:21 +00:00
|Name|Description|Example|
|--------------|-------------------------|-------------------------|
|[timeRange]| Over what time frame the affinities are compute. | `TimeRangeType.MediumTerm`
|[limit]| The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50. | `20`
|[offset]| The index of the first entity to return. Default: 0 (i.e., the first track). Use with limit to get the next set of entities. | `0`
Returns a [FullArtist](https://developer.spotify.com/web-api/object-model/#artist-object-full) wrapped inside a [Paging-object](https://developer.spotify.com/web-api/object-model/#paging-object)
2019-08-16 23:40:04 +01:00
**Usage**
2018-01-15 22:32:21 +00:00
```
Paging<FullArtist> artists = _spotify.GetUsersTopArtists();
artists.Items.ForEach(item => Console.WriteLine(item.Name)); //Display all fetched Artist-Names (max 20)
```
---
## GetUsersRecentlyPlayedTracks
> Get tracks from the current users recent play history.
2019-08-16 23:40:04 +01:00
**Parameters**
2018-01-15 22:32:21 +00:00
|Name|Description|Example|
|--------------|-------------------------|-------------------------|
|[limit]| The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50. | `20`
|[after]| Returns all items after (but not including) this cursor position. | `DateTime.Now.AddDays(-1)`
|[before]| Returns all items before (but not including) this cursor position. | `DateTime.Now.AddDays(-1)`
Returns a `PlayHistory` wrapped inside a [CursorPaging-object](https://developer.spotify.com/web-api/object-model/#cursor-based-paging-object)
2019-08-16 23:40:04 +01:00
**Usage**
2018-01-15 22:32:21 +00:00
```
CursorPaging<PlayHistory> histories = _spotify.GetUsersRecentlyPlayedTracks();
histories.Items.ForEach(item => Console.WriteLine(item.Track.Name));
```
---