I am a complete newbie to APIs and wanted to try it out with the Spotify API.
I use the Spotify API client from JohnnyCrazy and it works quite well so far. The authentication with the token works too.
As a test I wanted to display all songs of a given playlist, but found out that there is a request limit of 100 songs.
To get the next songs I would have to use the query parameter offset
as I read on the Spotify Developer website.
My question now is how to include the offset
parameter in the code with the Spotify API client.
This is my code:
var spotify = new SpotifyClient(MyToken);
var playlist = await spotify.Playlists.Get(MyPlaylistURI);
foreach (PlaylistTrack<IPlayableItem> item in playlist.Tracks.Items)
{
if (item.Track is FullTrack track)
{
Console.WriteLine(track.Name, track.Album.Name);
}
}
edit: MyPlaylistURI is just the Playlist ID. my bad
According to the documentation, offset
is a query parameter, meaning that you can just append it to the URI, i.e.
var MyPlaylistURI = "https://uri-you-are-using?offset=100"
var spotify = new SpotifyClient(MyToken);
var playlist = await spotify.Playlists.Get(MyPlaylistURI);
Of course, you would not hard code the offset. This is just to show how to include that parameter.