using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SpotifyAPI.Web.Enums;
using SpotifyAPI.Web.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
namespace SpotifyAPI.Web
{
public sealed class SpotifyWebAPI : IDisposable
{
[Obsolete("This Property will be removed soon. Please use SpotifyWebBuilder.APIBase")]
public const String APIBase = SpotifyWebBuilder.APIBase;
private readonly SpotifyWebBuilder _builder;
public SpotifyWebAPI()
{
_builder = new SpotifyWebBuilder();
UseAuth = true;
WebClient = new SpotifyWebClient
{
JsonSettings =
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
TypeNameHandling = TypeNameHandling.All
}
};
}
public String TokenType { get; set; }
public String AccessToken { get; set; }
public Boolean UseAuth { get; set; }
public IClient WebClient { get; set; }
public void Dispose()
{
WebClient.Dispose();
GC.SuppressFinalize(this);
}
#region Search
///
/// Get Spotify catalog information about artists, albums, tracks or playlists that match a keyword string.
///
/// The search query's keywords (and optional field filters and operators), for example q=roadhouse+blues.
/// A list of item types to search across.
/// The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50.
/// The index of the first result to return. Default: 0
/// An ISO 3166-1 alpha-2 country code or the string from_token.
///
public SearchItem SearchItems(String q, SearchType type, int limit = 20, int offset = 0, String market = "")
{
return DownloadData(_builder.SearchItems(q, type, limit, offset, market));
}
///
/// Get Spotify catalog information about artists, albums, tracks or playlists that match a keyword string asynchronously.
///
/// The search query's keywords (and optional field filters and operators), for example q=roadhouse+blues.
/// A list of item types to search across.
/// The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50.
/// The index of the first result to return. Default: 0
/// An ISO 3166-1 alpha-2 country code or the string from_token.
///
public async Task SearchItemsAsync(String q, SearchType type, int limit = 20, int offset = 0, String market = "")
{
return await DownloadDataAsync(_builder.SearchItems(q, type, limit, offset, market));
}
#endregion Search
#region Albums
///
/// Get Spotify catalog information about an album’s tracks. Optional parameters can be used to limit the number of
/// tracks returned.
///
/// The Spotify ID for the album.
/// The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50.
/// The index of the first track to return. Default: 0 (the first object).
/// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.
///
public Paging GetAlbumTracks(String id, int limit = 20, int offset = 0, String market = "")
{
return DownloadData>(_builder.GetAlbumTracks(id, limit, offset, market));
}
///
/// Get Spotify catalog information about an album’s tracks asynchronously. Optional parameters can be used to limit the number of
/// tracks returned.
///
/// The Spotify ID for the album.
/// The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50.
/// The index of the first track to return. Default: 0 (the first object).
/// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.
///
public async Task> GetAlbumTracksAsync(String id, int limit = 20, int offset = 0, String market = "")
{
return await DownloadDataAsync>(_builder.GetAlbumTracks(id, limit, offset, market));
}
///
/// Get Spotify catalog information for a single album.
///
/// The Spotify ID for the album.
/// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.
///
public FullAlbum GetAlbum(String id, String market = "")
{
return DownloadData(_builder.GetAlbum(id, market));
}
///
/// Get Spotify catalog information for a single album asynchronously.
///
/// The Spotify ID for the album.
/// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.
///
public async Task GetAlbumAsync(String id, String market = "")
{
return await DownloadDataAsync(_builder.GetAlbum(id, market));
}
///
/// Get Spotify catalog information for multiple albums identified by their Spotify IDs.
///
/// A list of the Spotify IDs for the albums. Maximum: 20 IDs.
/// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.
///
public SeveralAlbums GetSeveralAlbums(List ids, String market = "")
{
return DownloadData(_builder.GetSeveralAlbums(ids, market));
}
///
/// Get Spotify catalog information for multiple albums identified by their Spotify IDs asynchrously.
///
/// A list of the Spotify IDs for the albums. Maximum: 20 IDs.
/// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.
///
public async Task GetSeveralAlbumsAsync(List ids, String market = "")
{
return await DownloadDataAsync(_builder.GetSeveralAlbums(ids, market));
}
#endregion Albums
#region Artists
///
/// Get Spotify catalog information for a single artist identified by their unique Spotify ID.
///
/// The Spotify ID for the artist.
///
public FullArtist GetArtist(String id)
{
return DownloadData(_builder.GetArtist(id));
}
///
/// Get Spotify catalog information for a single artist identified by their unique Spotify ID asynchronously.
///
/// The Spotify ID for the artist.
///
public async Task GetArtistAsync(String id)
{
return await DownloadDataAsync(_builder.GetArtist(id));
}
///
/// Get Spotify catalog information about artists similar to a given artist. Similarity is based on analysis of the
/// Spotify community’s listening history.
///
/// The Spotify ID for the artist.
///
public SeveralArtists GetRelatedArtists(String id)
{
return DownloadData(_builder.GetRelatedArtists(id));
}
///
/// Get Spotify catalog information about artists similar to a given artist asynchronously. Similarity is based on analysis of the
/// Spotify community’s listening history.
///
/// The Spotify ID for the artist.
///
public async Task GetRelatedArtistsAsync(String id)
{
return await DownloadDataAsync(_builder.GetRelatedArtists(id));
}
///
/// Get Spotify catalog information about an artist’s top tracks by country.
///
/// The Spotify ID for the artist.
/// The country: an ISO 3166-1 alpha-2 country code.
///
public SeveralTracks GetArtistsTopTracks(String id, String country)
{
return DownloadData(_builder.GetArtistsTopTracks(id, country));
}
///
/// Get Spotify catalog information about an artist’s top tracks by country asynchronously.
///
/// The Spotify ID for the artist.
/// The country: an ISO 3166-1 alpha-2 country code.
///
public async Task GetArtistsTopTracksAsync(String id, String country)
{
return await DownloadDataAsync(_builder.GetArtistsTopTracks(id, country));
}
///
/// Get Spotify catalog information about an artist’s albums. Optional parameters can be specified in the query string
/// to filter and sort the response.
///
/// The Spotify ID for the artist.
///
/// A list of keywords that will be used to filter the response. If not supplied, all album types will
/// be returned
///
/// The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50.
/// The index of the first album to return. Default: 0
///
/// An ISO 3166-1 alpha-2 country code. Supply this parameter to limit the response to one particular
/// geographical market
///
///
public Paging GetArtistsAlbums(String id, AlbumType type = AlbumType.All, int limit = 20, int offset = 0, String market = "")
{
return DownloadData>(_builder.GetArtistsAlbums(id, type, limit, offset, market));
}
///
/// Get Spotify catalog information about an artist’s albums asynchronously. Optional parameters can be specified in the query string
/// to filter and sort the response.
///
/// The Spotify ID for the artist.
///
/// A list of keywords that will be used to filter the response. If not supplied, all album types will
/// be returned
///
/// The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50.
/// The index of the first album to return. Default: 0
///
/// An ISO 3166-1 alpha-2 country code. Supply this parameter to limit the response to one particular
/// geographical market
///
///
public async Task> GetArtistsAlbumsAsync(String id, AlbumType type = AlbumType.All, int limit = 20, int offset = 0, String market = "")
{
return await DownloadDataAsync>(_builder.GetArtistsAlbums(id, type, limit, offset, market));
}
///
/// Get Spotify catalog information for several artists based on their Spotify IDs.
///
/// A list of the Spotify IDs for the artists. Maximum: 50 IDs.
///
public SeveralArtists GetSeveralArtists(List ids)
{
return DownloadData(_builder.GetSeveralArtists(ids));
}
///
/// Get Spotify catalog information for several artists based on their Spotify IDs asynchronously.
///
/// A list of the Spotify IDs for the artists. Maximum: 50 IDs.
///
public async Task GetSeveralArtistsAsync(List ids)
{
return await DownloadDataAsync(_builder.GetSeveralArtists(ids));
}
#endregion Artists
#region Browse
///
/// Get a list of Spotify featured playlists (shown, for example, on a Spotify player’s “Browse” tab).
///
///
/// The desired language, consisting of a lowercase ISO 639 language code and an uppercase ISO 3166-1
/// alpha-2 country code, joined by an underscore.
///
/// A country: an ISO 3166-1 alpha-2 country code.
/// A timestamp in ISO 8601 format
/// The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50.
/// The index of the first item to return. Default: 0
/// AUTH NEEDED
public FeaturedPlaylists GetFeaturedPlaylists(String locale = "", String country = "", DateTime timestamp = default(DateTime), int limit = 20, int offset = 0)
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for GetFeaturedPlaylists");
return DownloadData(_builder.GetFeaturedPlaylists(locale, country, timestamp, limit, offset));
}
///
/// Get a list of Spotify featured playlists asynchronously (shown, for example, on a Spotify player’s “Browse” tab).
///
///
/// The desired language, consisting of a lowercase ISO 639 language code and an uppercase ISO 3166-1
/// alpha-2 country code, joined by an underscore.
///
/// A country: an ISO 3166-1 alpha-2 country code.
/// A timestamp in ISO 8601 format
/// The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50.
/// The index of the first item to return. Default: 0
/// AUTH NEEDED
public async Task GetFeaturedPlaylistsAsync(String locale = "", String country = "", DateTime timestamp = default(DateTime), int limit = 20, int offset = 0)
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for GetFeaturedPlaylists");
return await DownloadDataAsync(_builder.GetFeaturedPlaylists(locale, country, timestamp, limit, offset));
}
///
/// Get a list of new album releases featured in Spotify (shown, for example, on a Spotify player’s “Browse” tab).
///
/// A country: an ISO 3166-1 alpha-2 country code.
/// The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50.
/// The index of the first item to return. Default: 0
///
/// AUTH NEEDED
public NewAlbumReleases GetNewAlbumReleases(String country = "", int limit = 20, int offset = 0)
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for GetNewAlbumReleases");
return DownloadData(_builder.GetNewAlbumReleases(country, limit, offset));
}
///
/// Get a list of new album releases featured in Spotify asynchronously (shown, for example, on a Spotify player’s “Browse” tab).
///
/// A country: an ISO 3166-1 alpha-2 country code.
/// The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50.
/// The index of the first item to return. Default: 0
///
/// AUTH NEEDED
public async Task GetNewAlbumReleasesAsync(String country = "", int limit = 20, int offset = 0)
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for GetNewAlbumReleases");
return await DownloadDataAsync(_builder.GetNewAlbumReleases(country, limit, offset));
}
///
/// Get a list of categories used to tag items in Spotify (on, for example, the Spotify player’s “Browse” tab).
///
///
/// A country: an ISO 3166-1 alpha-2 country code. Provide this parameter if you want to narrow the
/// list of returned categories to those relevant to a particular country
///
///
/// The desired language, consisting of an ISO 639 language code and an ISO 3166-1 alpha-2 country
/// code, joined by an underscore
///
/// The maximum number of categories to return. Default: 20. Minimum: 1. Maximum: 50.
/// The index of the first item to return. Default: 0 (the first object).
///
/// AUTH NEEDED
public CategoryList GetCategories(String country = "", String locale = "", int limit = 20, int offset = 0)
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for GetCategories");
return DownloadData(_builder.GetCategories(country, locale, limit, offset));
}
///
/// Get a list of categories used to tag items in Spotify asynchronously (on, for example, the Spotify player’s “Browse” tab).
///
///
/// A country: an ISO 3166-1 alpha-2 country code. Provide this parameter if you want to narrow the
/// list of returned categories to those relevant to a particular country
///
///
/// The desired language, consisting of an ISO 639 language code and an ISO 3166-1 alpha-2 country
/// code, joined by an underscore
///
/// The maximum number of categories to return. Default: 20. Minimum: 1. Maximum: 50.
/// The index of the first item to return. Default: 0 (the first object).
///
/// AUTH NEEDED
public async Task GetCategoriesAsync(String country = "", String locale = "", int limit = 20, int offset = 0)
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for GetCategories");
return await DownloadDataAsync(_builder.GetCategories(country, locale, limit, offset));
}
///
/// Get a single category used to tag items in Spotify (on, for example, the Spotify player’s “Browse” tab).
///
/// The Spotify category ID for the category.
///
/// A country: an ISO 3166-1 alpha-2 country code. Provide this parameter to ensure that the category
/// exists for a particular country.
///
///
/// The desired language, consisting of an ISO 639 language code and an ISO 3166-1 alpha-2 country
/// code, joined by an underscore
///
///
/// AUTH NEEDED
public Category GetCategory(String categoryId, String country = "", String locale = "")
{
return DownloadData(_builder.GetCategory(categoryId, country, locale));
}
///
/// Get a single category used to tag items in Spotify asynchronously (on, for example, the Spotify player’s “Browse” tab).
///
/// The Spotify category ID for the category.
///
/// A country: an ISO 3166-1 alpha-2 country code. Provide this parameter to ensure that the category
/// exists for a particular country.
///
///
/// The desired language, consisting of an ISO 639 language code and an ISO 3166-1 alpha-2 country
/// code, joined by an underscore
///
///
/// AUTH NEEDED
public async Task GetCategoryAsync(String categoryId, String country = "", String locale = "")
{
return await DownloadDataAsync(_builder.GetCategory(categoryId, country, locale));
}
///
/// Get a list of Spotify playlists tagged with a particular category.
///
/// The Spotify category ID for the category.
/// A country: an ISO 3166-1 alpha-2 country code.
/// The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50.
/// The index of the first item to return. Default: 0
///
/// AUTH NEEDED
public CategoryPlaylist GetCategoryPlaylists(String categoryId, String country = "", int limit = 20, int offset = 0)
{
return DownloadData(_builder.GetCategoryPlaylists(categoryId, country, limit, offset));
}
///
/// Get a list of Spotify playlists tagged with a particular category asynchronously.
///
/// The Spotify category ID for the category.
/// A country: an ISO 3166-1 alpha-2 country code.
/// The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50.
/// The index of the first item to return. Default: 0
///
/// AUTH NEEDED
public async Task GetCategoryPlaylistsAsync(String categoryId, String country = "", int limit = 20, int offset = 0)
{
return await DownloadDataAsync(_builder.GetCategoryPlaylists(categoryId, country, limit, offset));
}
#endregion Browse
#region Follow
///
/// Get the current user’s followed artists.
///
/// The ID type: currently only artist is supported.
/// The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50.
/// The last artist ID retrieved from the previous request.
///
/// AUTH NEEDED
public FollowedArtists GetFollowedArtists(FollowType followType, int limit = 20, String after = "")
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for GetFollowedArtists");
return DownloadData(_builder.GetFollowedArtists(limit, after));
}
///
/// Get the current user’s followed artists asynchronously.
///
/// The ID type: currently only artist is supported.
/// The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50.
/// The last artist ID retrieved from the previous request.
///
/// AUTH NEEDED
public async Task GetFollowedArtistsAsync(FollowType followType, int limit = 20, String after = "")
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for GetFollowedArtists");
return await DownloadDataAsync(_builder.GetFollowedArtists(limit, after));
}
///
/// Add the current user as a follower of one or more artists or other Spotify users.
///
/// The ID type: either artist or user.
/// A list of the artist or the user Spotify IDs
///
/// AUTH NEEDED
public ErrorResponse Follow(FollowType followType, List ids)
{
JObject ob = new JObject
{
{"ids", new JArray(ids)}
};
return UploadData(_builder.Follow(followType), ob.ToString(Formatting.None), "PUT") ?? new ErrorResponse();
}
///
/// Add the current user as a follower of one or more artists or other Spotify users asynchronously.
///
/// The ID type: either artist or user.
/// A list of the artist or the user Spotify IDs
///
/// AUTH NEEDED
public async Task FollowAsync(FollowType followType, List ids)
{
JObject ob = new JObject
{
{"ids", new JArray(ids)}
};
return await
UploadDataAsync(_builder.Follow(followType),
ob.ToString(Formatting.None), "PUT") ?? new ErrorResponse();
}
///
/// Add the current user as a follower of one or more artists or other Spotify users.
///
/// The ID type: either artist or user.
/// Artists or the Users Spotify ID
///
/// AUTH NEEDED
public ErrorResponse Follow(FollowType followType, String id)
{
return Follow(followType, new List { id });
}
///
/// Add the current user as a follower of one or more artists or other Spotify users asynchronously.
///
/// The ID type: either artist or user.
/// Artists or the Users Spotify ID
///
/// AUTH NEEDED
public async Task FollowAsync(FollowType followType, String id)
{
return await FollowAsync(followType, new List { id });
}
///
/// Remove the current user as a follower of one or more artists or other Spotify users.
///
/// The ID type: either artist or user.
/// A list of the artist or the user Spotify IDs
///
/// AUTH NEEDED
public ErrorResponse Unfollow(FollowType followType, List ids)
{
JObject ob = new JObject
{
{"ids", new JArray(ids)}
};
return UploadData(_builder.Unfollow(followType), ob.ToString(Formatting.None), "DELETE") ?? new ErrorResponse();
}
///
/// Remove the current user as a follower of one or more artists or other Spotify users asynchronously.
///
/// The ID type: either artist or user.
/// A list of the artist or the user Spotify IDs
///
/// AUTH NEEDED
public async Task UnfollowAsync(FollowType followType, List ids)
{
JObject ob = new JObject
{
{"ids", new JArray(ids)}
};
return await UploadDataAsync(_builder.Unfollow(followType), ob.ToString(Formatting.None), "DELETE") ?? new ErrorResponse();
}
///
/// Remove the current user as a follower of one or more artists or other Spotify users.
///
/// The ID type: either artist or user.
/// Artists or the Users Spotify ID
///
/// AUTH NEEDED
public ErrorResponse Unfollow(FollowType followType, String id)
{
return Unfollow(followType, new List { id });
}
///
/// Remove the current user as a follower of one or more artists or other Spotify users asynchronously.
///
/// The ID type: either artist or user.
/// Artists or the Users Spotify ID
///
/// AUTH NEEDED
public async Task UnfollowAsync(FollowType followType, String id)
{
return await UnfollowAsync(followType, new List { id });
}
///
/// Check to see if the current user is following one or more artists or other Spotify users.
///
/// The ID type: either artist or user.
/// A list of the artist or the user Spotify IDs to check
///
/// AUTH NEEDED
public ListResponse IsFollowing(FollowType followType, List ids)
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for IsFollowing");
JToken res = DownloadData(_builder.IsFollowing(followType, ids));
if (res is JArray)
return new ListResponse { List = res.ToObject>(), Error = null };
return new ListResponse { List = null, Error = res["error"].ToObject() };
}
///
/// Check to see if the current user is following one or more artists or other Spotify users asynchronously.
///
/// The ID type: either artist or user.
/// A list of the artist or the user Spotify IDs to check
///
/// AUTH NEEDED
public async Task> IsFollowingAsync(FollowType followType, List ids)
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for IsFollowing");
JToken res = await DownloadDataAsync(_builder.IsFollowing(followType, ids));
if (res is JArray)
return new ListResponse { List = res.ToObject>(), Error = null };
return new ListResponse { List = null, Error = res["error"].ToObject() };
}
///
/// Check to see if the current user is following one artist or another Spotify user.
///
/// The ID type: either artist or user.
/// Artists or the Users Spotify ID
///
/// AUTH NEEDED
public ListResponse IsFollowing(FollowType followType, String id)
{
return IsFollowing(followType, new List { id });
}
///
/// Check to see if the current user is following one artist or another Spotify user asynchronously.
///
/// The ID type: either artist or user.
/// Artists or the Users Spotify ID
///
/// AUTH NEEDED
public async Task> IsFollowingAsync(FollowType followType, String id)
{
return await IsFollowingAsync(followType, new List { id });
}
///
/// Add the current user as a follower of a playlist.
///
/// The Spotify user ID of the person who owns the playlist.
///
/// The Spotify ID of the playlist. Any playlist can be followed, regardless of its public/private
/// status, as long as you know its playlist ID.
///
///
/// If true the playlist will be included in user's public playlists, if false it will remain
/// private.
///
///
/// AUTH NEEDED
public ErrorResponse FollowPlaylist(String ownerId, String playlistId, bool showPublic = true)
{
JObject body = new JObject
{
{"public", showPublic}
};
return UploadData(_builder.FollowPlaylist(ownerId, playlistId, showPublic), body.ToString(Formatting.None), "PUT");
}
///
/// Add the current user as a follower of a playlist asynchronously.
///
/// The Spotify user ID of the person who owns the playlist.
///
/// The Spotify ID of the playlist. Any playlist can be followed, regardless of its public/private
/// status, as long as you know its playlist ID.
///
///
/// If true the playlist will be included in user's public playlists, if false it will remain
/// private.
///
///
/// AUTH NEEDED
public async Task FollowPlaylistAsync(String ownerId, String playlistId, bool showPublic = true)
{
JObject body = new JObject
{
{"public", showPublic}
};
return await UploadDataAsync(_builder.FollowPlaylist(ownerId, playlistId, showPublic), body.ToString(Formatting.None), "PUT");
}
///
/// Remove the current user as a follower of a playlist.
///
/// The Spotify user ID of the person who owns the playlist.
/// The Spotify ID of the playlist that is to be no longer followed.
///
/// AUTH NEEDED
public ErrorResponse UnfollowPlaylist(String ownerId, String playlistId)
{
return UploadData(_builder.UnfollowPlaylist(ownerId, playlistId), "", "DELETE");
}
///
/// Remove the current user as a follower of a playlist asynchronously.
///
/// The Spotify user ID of the person who owns the playlist.
/// The Spotify ID of the playlist that is to be no longer followed.
///
/// AUTH NEEDED
public async Task UnfollowPlaylistAsync(String ownerId, String playlistId)
{
return await UploadDataAsync(_builder.UnfollowPlaylist(ownerId, playlistId), "", "DELETE");
}
///
/// Check to see if one or more Spotify users are following a specified playlist.
///
/// The Spotify user ID of the person who owns the playlist.
/// The Spotify ID of the playlist.
/// A list of Spotify User IDs
///
/// AUTH NEEDED
public ListResponse IsFollowingPlaylist(String ownerId, String playlistId, List ids)
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for IsFollowingPlaylist");
JToken res = DownloadData(_builder.IsFollowingPlaylist(ownerId, playlistId, ids));
if (res is JArray)
return new ListResponse { List = res.ToObject>(), Error = null };
return new ListResponse { List = null, Error = res["error"].ToObject() };
}
///
/// Check to see if one or more Spotify users are following a specified playlist asynchronously.
///
/// The Spotify user ID of the person who owns the playlist.
/// The Spotify ID of the playlist.
/// A list of Spotify User IDs
///
/// AUTH NEEDED
public async Task> IsFollowingPlaylistAsync(String ownerId, String playlistId, List ids)
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for IsFollowingPlaylist");
JToken res = await DownloadDataAsync(_builder.IsFollowingPlaylist(ownerId, playlistId, ids));
if (res is JArray)
return new ListResponse { List = res.ToObject>(), Error = null };
return new ListResponse { List = null, Error = res["error"].ToObject() };
}
///
/// Check to see if one or more Spotify users are following a specified playlist.
///
/// The Spotify user ID of the person who owns the playlist.
/// The Spotify ID of the playlist.
/// A Spotify User ID
///
/// AUTH NEEDED
public ListResponse IsFollowingPlaylist(String ownerId, String playlistId, String id)
{
return IsFollowingPlaylist(ownerId, playlistId, new List { id });
}
///
/// Check to see if one or more Spotify users are following a specified playlist asynchronously.
///
/// The Spotify user ID of the person who owns the playlist.
/// The Spotify ID of the playlist.
/// A Spotify User ID
///
/// AUTH NEEDED
public async Task> IsFollowingPlaylistAsync(String ownerId, String playlistId, String id)
{
return await IsFollowingPlaylistAsync(ownerId, playlistId, new List { id });
}
#endregion Follow
#region Library
///
/// Save one or more tracks to the current user’s “Your Music” library.
///
/// A list of the Spotify IDs
///
/// AUTH NEEDED
public ErrorResponse SaveTracks(List ids)
{
JArray array = new JArray(ids);
return UploadData(_builder.SaveTracks(), array.ToString(Formatting.None), "PUT") ?? new ErrorResponse();
}
///
/// Save one or more tracks to the current user’s “Your Music” library asynchronously.
///
/// A list of the Spotify IDs
///
/// AUTH NEEDED
public async Task SaveTracksAsync(List ids)
{
JArray array = new JArray(ids);
return await UploadDataAsync(_builder.SaveTracks(), array.ToString(Formatting.None), "PUT") ?? new ErrorResponse();
}
///
/// Save one track to the current user’s “Your Music” library.
///
/// A Spotify ID
///
/// AUTH NEEDED
public ErrorResponse SaveTrack(String id)
{
return SaveTracks(new List { id });
}
///
/// Save one track to the current user’s “Your Music” library asynchronously.
///
/// A Spotify ID
///
/// AUTH NEEDED
public async Task SaveTrackAsync(String id)
{
return await SaveTracksAsync(new List { id });
}
///
/// Get a list of the songs saved in the current Spotify user’s “Your Music” library.
///
/// The maximum number of objects to return. Default: 20. Minimum: 1. Maximum: 50.
/// The index of the first object to return. Default: 0 (i.e., the first object)
/// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.
///
/// AUTH NEEDED
public Paging GetSavedTracks(int limit = 20, int offset = 0, String market = "")
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for GetSavedTracks");
return DownloadData>(_builder.GetSavedTracks(limit, offset, market));
}
///
/// Get a list of the songs saved in the current Spotify user’s “Your Music” library asynchronously.
///
/// The maximum number of objects to return. Default: 20. Minimum: 1. Maximum: 50.
/// The index of the first object to return. Default: 0 (i.e., the first object)
/// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.
///
/// AUTH NEEDED
public async Task> GetSavedTracksAsync(int limit = 20, int offset = 0, String market = "")
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for GetSavedTracks");
return await DownloadDataAsync>(_builder.GetSavedTracks(limit, offset, market));
}
///
/// Remove one or more tracks from the current user’s “Your Music” library.
///
/// A list of the Spotify IDs.
///
/// AUTH NEEDED
public ErrorResponse RemoveSavedTracks(List ids)
{
JArray array = new JArray(ids);
return UploadData(_builder.RemoveSavedTracks(), array.ToString(Formatting.None), "DELETE") ?? new ErrorResponse();
}
///
/// Remove one or more tracks from the current user’s “Your Music” library asynchronously.
///
/// A list of the Spotify IDs.
///
/// AUTH NEEDED
public async Task RemoveSavedTracksAsync(List ids)
{
JArray array = new JArray(ids);
return await UploadDataAsync(_builder.RemoveSavedTracks(), array.ToString(Formatting.None), "DELETE") ?? new ErrorResponse();
}
///
/// Check if one or more tracks is already saved in the current Spotify user’s “Your Music” library.
///
/// A list of the Spotify IDs.
///
/// AUTH NEEDED
public ListResponse CheckSavedTracks(List ids)
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for CheckSavedTracks");
JToken res = DownloadData(_builder.CheckSavedTracks(ids));
if (res is JArray)
return new ListResponse { List = res.ToObject>(), Error = null };
return new ListResponse { List = null, Error = res["error"].ToObject() };
}
///
/// Check if one or more tracks is already saved in the current Spotify user’s “Your Music” library asynchronously.
///
/// A list of the Spotify IDs.
///
/// AUTH NEEDED
public async Task> CheckSavedTracksAsync(List ids)
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for CheckSavedTracks");
JToken res = await DownloadDataAsync(_builder.CheckSavedTracks(ids));
if (res is JArray)
return new ListResponse { List = res.ToObject>(), Error = null };
return new ListResponse { List = null, Error = res["error"].ToObject() };
}
#endregion Library
#region Playlists
///
/// Get a list of the playlists owned or followed by a Spotify user.
///
/// The user's Spotify user ID.
/// The maximum number of playlists to return. Default: 20. Minimum: 1. Maximum: 50.
/// The index of the first playlist to return. Default: 0 (the first object)
///
/// AUTH NEEDED
public Paging GetUserPlaylists(String userId, int limit = 20, int offset = 0)
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for GetUserPlaylists");
return DownloadData>(_builder.GetUserPlaylists(userId, limit, offset));
}
///
/// Get a list of the playlists owned or followed by a Spotify user asynchronously.
///
/// The user's Spotify user ID.
/// The maximum number of playlists to return. Default: 20. Minimum: 1. Maximum: 50.
/// The index of the first playlist to return. Default: 0 (the first object)
///
/// AUTH NEEDED
public async Task> GetUserPlaylistsAsync(String userId, int limit = 20, int offset = 0)
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for GetUserPlaylists");
return await DownloadDataAsync>(_builder.GetUserPlaylists(userId, limit, offset));
}
///
/// Get a playlist owned by a Spotify user.
///
/// The user's Spotify user ID.
/// The Spotify ID for the playlist.
///
/// Filters for the query: a comma-separated list of the fields to return. If omitted, all fields are
/// returned.
///
/// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.
///
/// AUTH NEEDED
public FullPlaylist GetPlaylist(String userId, String playlistId, String fields = "", String market = "")
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for GetPlaylist");
return DownloadData(_builder.GetPlaylist(userId, playlistId, fields, market));
}
///
/// Get a playlist owned by a Spotify user asynchronously.
///
/// The user's Spotify user ID.
/// The Spotify ID for the playlist.
///
/// Filters for the query: a comma-separated list of the fields to return. If omitted, all fields are
/// returned.
///
/// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.
///
/// AUTH NEEDED
public async Task GetPlaylistAsync(String userId, String playlistId, String fields = "", String market = "")
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for GetPlaylist");
return await DownloadDataAsync(_builder.GetPlaylist(userId, playlistId, fields, market));
}
///
/// Get full details of the tracks of a playlist owned by a Spotify user.
///
/// The user's Spotify user ID.
/// The Spotify ID for the playlist.
///
/// Filters for the query: a comma-separated list of the fields to return. If omitted, all fields are
/// returned.
///
/// The maximum number of tracks to return. Default: 100. Minimum: 1. Maximum: 100.
/// The index of the first object to return. Default: 0 (i.e., the first object)
/// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.
///
/// AUTH NEEDED
public Paging GetPlaylistTracks(String userId, String playlistId, String fields = "", int limit = 100, int offset = 0, String market = "")
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for GetPlaylistTracks");
return DownloadData>(_builder.GetPlaylistTracks(userId, playlistId, fields, limit, offset, market));
}
///
/// Get full details of the tracks of a playlist owned by a Spotify user asyncronously.
///
/// The user's Spotify user ID.
/// The Spotify ID for the playlist.
///
/// Filters for the query: a comma-separated list of the fields to return. If omitted, all fields are
/// returned.
///
/// The maximum number of tracks to return. Default: 100. Minimum: 1. Maximum: 100.
/// The index of the first object to return. Default: 0 (i.e., the first object)
/// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.
///
/// AUTH NEEDED
public async Task> GetPlaylistTracksAsync(String userId, String playlistId, String fields = "", int limit = 100, int offset = 0, String market = "")
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for GetPlaylistTracks");
return await DownloadDataAsync>(_builder.GetPlaylistTracks(userId, playlistId, fields, limit, offset, market));
}
///
/// Create a playlist for a Spotify user. (The playlist will be empty until you add tracks.)
///
/// The user's Spotify user ID.
///
/// The name for the new playlist, for example "Your Coolest Playlist". This name does not need
/// to be unique.
///
///
/// default true. If true the playlist will be public, if false it will be private. To be able to
/// create private playlists, the user must have granted the playlist-modify-private scope.
///
///
/// AUTH NEEDED
public FullPlaylist CreatePlaylist(String userId, String playlistName, Boolean isPublic = true)
{
JObject body = new JObject
{
{"name", playlistName},
{"public", isPublic}
};
return UploadData(_builder.CreatePlaylist(userId, playlistName, isPublic), body.ToString(Formatting.None));
}
///
/// Create a playlist for a Spotify user asynchronously. (The playlist will be empty until you add tracks.)
///
/// The user's Spotify user ID.
///
/// The name for the new playlist, for example "Your Coolest Playlist". This name does not need
/// to be unique.
///
///
/// default true. If true the playlist will be public, if false it will be private. To be able to
/// create private playlists, the user must have granted the playlist-modify-private scope.
///
///
/// AUTH NEEDED
public async Task CreatePlaylistAsync(String userId, String playlistName, Boolean isPublic = true)
{
JObject body = new JObject
{
{"name", playlistName},
{"public", isPublic}
};
return await UploadDataAsync(_builder.CreatePlaylist(userId, playlistName, isPublic), body.ToString(Formatting.None));
}
///
/// Change a playlist’s name and public/private state. (The user must, of course, own the playlist.)
///
/// The user's Spotify user ID.
/// The Spotify ID for the playlist.
/// The new name for the playlist, for example "My New Playlist Title".
/// If true the playlist will be public, if false it will be private.
///
/// AUTH NEEDED
public ErrorResponse UpdatePlaylist(String userId, String playlistId, String newName = null, Boolean? newPublic = null)
{
JObject body = new JObject();
if (newName != null)
body.Add("name", newName);
if (newPublic != null)
body.Add("public", newPublic);
return UploadData(_builder.UpdatePlaylist(userId, playlistId), body.ToString(Formatting.None), "PUT") ?? new ErrorResponse();
}
///
/// Change a playlist’s name and public/private state asynchronously. (The user must, of course, own the playlist.)
///
/// The user's Spotify user ID.
/// The Spotify ID for the playlist.
/// The new name for the playlist, for example "My New Playlist Title".
/// If true the playlist will be public, if false it will be private.
///
/// AUTH NEEDED
public async Task UpdatePlaylistAsync(String userId, String playlistId, String newName = null, Boolean? newPublic = null)
{
JObject body = new JObject();
if (newName != null)
body.Add("name", newName);
if (newPublic != null)
body.Add("public", newPublic);
return await UploadDataAsync(_builder.UpdatePlaylist(userId, playlistId), body.ToString(Formatting.None), "PUT") ?? new ErrorResponse();
}
///
/// Replace all the tracks in a playlist, overwriting its existing tracks. This powerful request can be useful for
/// replacing tracks, re-ordering existing tracks, or clearing the playlist.
///
/// The user's Spotify user ID.
/// The Spotify ID for the playlist.
/// A list of Spotify track URIs to set. A maximum of 100 tracks can be set in one request.
///
/// AUTH NEEDED
public ErrorResponse ReplacePlaylistTracks(String userId, String playlistId, List uris)
{
JObject body = new JObject
{
{"uris", new JArray(uris.Take(100))}
};
return UploadData(_builder.ReplacePlaylistTracks(userId, playlistId), body.ToString(Formatting.None), "PUT") ?? new ErrorResponse();
}
///
/// Replace all the tracks in a playlist asynchronously, overwriting its existing tracks. This powerful request can be useful for
/// replacing tracks, re-ordering existing tracks, or clearing the playlist.
///
/// The user's Spotify user ID.
/// The Spotify ID for the playlist.
/// A list of Spotify track URIs to set. A maximum of 100 tracks can be set in one request.
///
/// AUTH NEEDED
public async Task ReplacePlaylistTracksAsync(String userId, String playlistId, List uris)
{
JObject body = new JObject
{
{"uris", new JArray(uris.Take(100))}
};
return await UploadDataAsync(_builder.ReplacePlaylistTracks(userId, playlistId), body.ToString(Formatting.None), "PUT") ?? new ErrorResponse();
}
///
/// Remove one or more tracks from a user’s playlist.
///
/// The user's Spotify user ID.
/// The Spotify ID for the playlist.
///
/// array of objects containing Spotify URI strings (and their position in the playlist). A maximum of
/// 100 objects can be sent at once.
///
///
/// AUTH NEEDED
public ErrorResponse RemovePlaylistTracks(String userId, String playlistId, List uris)
{
JObject body = new JObject
{
{"tracks", JArray.FromObject(uris.Take(100))}
};
return UploadData(_builder.RemovePlaylistTracks(userId, playlistId, uris), body.ToString(Formatting.None), "DELETE") ?? new ErrorResponse();
}
///
/// Remove one or more tracks from a user’s playlist asynchronously.
///
/// The user's Spotify user ID.
/// The Spotify ID for the playlist.
///
/// array of objects containing Spotify URI strings (and their position in the playlist). A maximum of
/// 100 objects can be sent at once.
///
///
/// AUTH NEEDED
public async Task RemovePlaylistTracksAsync(String userId, String playlistId, List uris)
{
JObject body = new JObject
{
{"tracks", JArray.FromObject(uris.Take(100))}
};
return await UploadDataAsync(_builder.RemovePlaylistTracks(userId, playlistId, uris), body.ToString(Formatting.None), "DELETE") ?? new ErrorResponse();
}
///
/// Remove one or more tracks from a user’s playlist.
///
/// The user's Spotify user ID.
/// The Spotify ID for the playlist.
/// Spotify URI
///
/// AUTH NEEDED
public ErrorResponse RemovePlaylistTrack(String userId, String playlistId, DeleteTrackUri uri)
{
return RemovePlaylistTracks(userId, playlistId, new List { uri });
}
///
/// Remove one or more tracks from a user’s playlist asynchronously.
///
/// The user's Spotify user ID.
/// The Spotify ID for the playlist.
/// Spotify URI
///
/// AUTH NEEDED
public async Task RemovePlaylistTrackAsync(String userId, String playlistId, DeleteTrackUri uri)
{
return await RemovePlaylistTracksAsync(userId, playlistId, new List { uri });
}
///
/// Add one or more tracks to a user’s playlist.
///
/// The user's Spotify user ID.
/// The Spotify ID for the playlist.
/// A list of Spotify track URIs to add
/// The position to insert the tracks, a zero-based index
///
/// AUTH NEEDED
public ErrorResponse AddPlaylistTracks(String userId, String playlistId, List uris, int? position = null)
{
JObject body = new JObject
{
{"uris", JArray.FromObject(uris.Take(100))}
};
return UploadData(_builder.AddPlaylistTracks(userId, playlistId, uris, position), body.ToString(Formatting.None)) ?? new ErrorResponse();
}
///
/// Add one or more tracks to a user’s playlist asynchronously.
///
/// The user's Spotify user ID.
/// The Spotify ID for the playlist.
/// A list of Spotify track URIs to add
/// The position to insert the tracks, a zero-based index
///
/// AUTH NEEDED
public async Task AddPlaylistTracksAsync(String userId, String playlistId, List uris, int? position = null)
{
JObject body = new JObject
{
{"uris", JArray.FromObject(uris.Take(100))}
};
return await UploadDataAsync(_builder.AddPlaylistTracks(userId, playlistId, uris, position), body.ToString(Formatting.None)) ?? new ErrorResponse();
}
///
/// Add one or more tracks to a user’s playlist.
///
/// The user's Spotify user ID.
/// The Spotify ID for the playlist.
/// A Spotify Track URI
/// The position to insert the tracks, a zero-based index
///
/// AUTH NEEDED
public ErrorResponse AddPlaylistTrack(String userId, String playlistId, String uri, int? position = null)
{
return AddPlaylistTracks(userId, playlistId, new List { uri }, position);
}
///
/// Add one or more tracks to a user’s playlist asynchronously.
///
/// The user's Spotify user ID.
/// The Spotify ID for the playlist.
/// A Spotify Track URI
/// The position to insert the tracks, a zero-based index
///
/// AUTH NEEDED
public async Task AddPlaylistTrackAsync(String userId, String playlistId, String uri, int? position = null)
{
return await AddPlaylistTracksAsync(userId, playlistId, new List { uri }, position);
}
///
/// Reorder a track or a group of tracks in a playlist.
///
/// The user's Spotify user ID.
/// The Spotify ID for the playlist.
/// The position of the first track to be reordered.
/// The position where the tracks should be inserted.
/// The amount of tracks to be reordered. Defaults to 1 if not set.
/// The playlist's snapshot ID against which you want to make the changes.
///
/// AUTH NEEDED
public Snapshot ReorderPlaylist(String userId, String playlistId, int rangeStart, int insertBefore, int rangeLength = 1, String snapshotId = "")
{
JObject body = new JObject
{
{"range_start", rangeStart},
{"range_length", rangeLength},
{"insert_before", insertBefore}
};
if (!String.IsNullOrEmpty(snapshotId))
body.Add("snapshot_id", snapshotId);
return UploadData(_builder.ReorderPlaylist(userId, playlistId), body.ToString(Formatting.None), "PUT");
}
///
/// Reorder a track or a group of tracks in a playlist asynchronously.
///
/// The user's Spotify user ID.
/// The Spotify ID for the playlist.
/// The position of the first track to be reordered.
/// The position where the tracks should be inserted.
/// The amount of tracks to be reordered. Defaults to 1 if not set.
/// The playlist's snapshot ID against which you want to make the changes.
///
/// AUTH NEEDED
public async Task ReorderPlaylistAsync(String userId, String playlistId, int rangeStart, int insertBefore, int rangeLength = 1, String snapshotId = "")
{
JObject body = new JObject
{
{"range_start", rangeStart},
{"range_length", rangeLength},
{"insert_before", insertBefore},
{"snapshot_id", snapshotId}
};
if (!String.IsNullOrEmpty(snapshotId))
body.Add("snapshot_id", snapshotId);
return await UploadDataAsync(_builder.ReorderPlaylist(userId, playlistId), body.ToString(Formatting.None), "PUT");
}
#endregion Playlists
#region Profiles
///
/// Get detailed profile information about the current user (including the current user’s username).
///
///
/// AUTH NEEDED
public PrivateProfile GetPrivateProfile()
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for GetPrivateProfile");
return DownloadData(_builder.GetPrivateProfile());
}
///
/// Get detailed profile information about the current user asynchronously (including the current user’s username).
///
///
/// AUTH NEEDED
public async Task GetPrivateProfileAsync()
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for GetPrivateProfile");
return await DownloadDataAsync(_builder.GetPrivateProfile());
}
///
/// Get public profile information about a Spotify user.
///
/// The user's Spotify user ID.
///
public PublicProfile GetPublicProfile(String userId)
{
return DownloadData(_builder.GetPublicProfile(userId));
}
///
/// Get public profile information about a Spotify user asynchronously.
///
/// The user's Spotify user ID.
///
public async Task GetPublicProfileAsync(String userId)
{
return await DownloadDataAsync(_builder.GetPublicProfile(userId));
}
#endregion Profiles
#region Tracks
///
/// Get Spotify catalog information for multiple tracks based on their Spotify IDs.
///
/// A list of the Spotify IDs for the tracks. Maximum: 50 IDs.
/// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.
///
public SeveralTracks GetSeveralTracks(List ids, String market = "")
{
return DownloadData(_builder.GetSeveralTracks(ids, market));
}
///
/// Get Spotify catalog information for multiple tracks based on their Spotify IDs asynchronously.
///
/// A list of the Spotify IDs for the tracks. Maximum: 50 IDs.
/// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.
///
public async Task GetSeveralTracksAsync(List ids, String market = "")
{
return await DownloadDataAsync(_builder.GetSeveralTracks(ids, market));
}
///
/// Get Spotify catalog information for a single track identified by its unique Spotify ID.
///
/// The Spotify ID for the track.
/// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.
///
public FullTrack GetTrack(String id, String market = "")
{
return DownloadData(_builder.GetTrack(id, market));
}
///
/// Get Spotify catalog information for a single track identified by its unique Spotify ID asynchronously.
///
/// The Spotify ID for the track.
/// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.
///
public async Task GetTrackAsync(String id, String market = "")
{
return await DownloadDataAsync(_builder.GetTrack(id, market));
}
#endregion Tracks
#region Util
public Paging GetNextPage(Paging paging)
{
if (!paging.HasNextPage())
throw new InvalidOperationException("This Paging-Object has no Next-Page");
return DownloadData>(paging.Next);
}
public async Task> GetNextPageAsync(Paging paging)
{
if (!paging.HasNextPage())
throw new InvalidOperationException("This Paging-Object has no Next-Page");
return await DownloadDataAsync>(paging.Next);
}
public Paging GetPreviousPage(Paging paging)
{
if (!paging.HasPreviousPage())
throw new InvalidOperationException("This Paging-Object has no Previous-Page");
return DownloadData>(paging.Previous);
}
public async Task> GetPreviousPageAsync(Paging paging)
{
if (!paging.HasPreviousPage())
throw new InvalidOperationException("This Paging-Object has no Previous-Page");
return await DownloadDataAsync>(paging.Previous);
}
public T UploadData(String url, String uploadData, String method = "POST")
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for all Upload-Actions");
WebClient.SetHeader("Authorization", TokenType + " " + AccessToken);
WebClient.SetHeader("Content-Type", "application/json");
return WebClient.UploadJson(url, uploadData, method);
}
public Task UploadDataAsync(String url, String uploadData, String method = "POST")
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for all Upload-Actions");
WebClient.SetHeader("Authorization", TokenType + " " + AccessToken);
WebClient.SetHeader("Content-Type", "application/json");
return WebClient.UploadJsonAsync(url, uploadData, method);
}
public T DownloadData(String url)
{
if (UseAuth)
WebClient.SetHeader("Authorization", TokenType + " " + AccessToken);
else
WebClient.RemoveHeader("Authorization");
return WebClient.DownloadJson(url);
}
public Task DownloadDataAsync(String url)
{
if (UseAuth)
WebClient.SetHeader("Authorization", TokenType + " " + AccessToken);
else
WebClient.RemoveHeader("Authorization");
return WebClient.DownloadJsonAsync(url);
}
#endregion Util
}
}