With it, you can search for Tracks/Albums/Artists and also get User-based information.
It's also possible to create new playlists and add tracks to it.</p><h2id="first-steps"><ahref="#first-steps"aria-hidden="true"class="header-anchor">#</a> First steps</h2><h3id="imports"><ahref="#imports"aria-hidden="true"class="header-anchor">#</a> Imports</h3><p>So after you added the API to your project, you may want to add following imports to your files:</p><divclass="language-csharp extra-class"><preclass="language-csharp"><code><spanclass="token keyword">using</span> SpotifyAPI<spanclass="token punctuation">.</span>Web<spanclass="token punctuation">;</span><spanclass="token comment">//Base Namespace</span>
<spanclass="token keyword">using</span> SpotifyAPI<spanclass="token punctuation">.</span>Web<spanclass="token punctuation">.</span>Models<spanclass="token punctuation">;</span><spanclass="token comment">//Models for the JSON-responses</span>
</code></pre></div><h3id="basic-usage"><ahref="#basic-usage"aria-hidden="true"class="header-anchor">#</a> Basic-Usage</h3><p>Now you can actually start doing calls to the SpotifyAPI, just create a new Instance of SpotifyWebAPI:</p><divclass="language-csharp extra-class"><preclass="language-csharp"><code><spanclass="token keyword">private</span><spanclass="token keyword">static</span><spanclass="token class-name">SpotifyWebAPI</span> _spotify<spanclass="token punctuation">;</span>
Console<spanclass="token punctuation">.</span><spanclass="token function">WriteLine</span><spanclass="token punctuation">(</span>track<spanclass="token punctuation">.</span>Name<spanclass="token punctuation">)</span><spanclass="token punctuation">;</span><spanclass="token comment">//Yeay! We just printed a tracks name.</span>
<spanclass="token punctuation">}</span>
</code></pre></div><p>You may note that we used <code>AccessToken</code> and <code>TokenType</code>. Spotify does not allow un-authorized access to their API. You will need to implement one of the auth flows. Luckily, <code>SpotifyAPI.Web.Auth</code> exists for this reason. A simple way to receive a <code>AccessToken</code> is via <code>CredentialAuth</code>:</p><divclass="language-csharp extra-class"><preclass="language-csharp"><code><spanclass="token class-name">CredentialsAuth</span> auth <spanclass="token operator">=</span><spanclass="token keyword">new</span><spanclass="token class-name">CredentialsAuth</span><spanclass="token punctuation">(</span><spanclass="token string">"YourClientID"</span><spanclass="token punctuation">,</span><spanclass="token string">"YourClientSecret"</span><spanclass="token punctuation">)</span><spanclass="token punctuation">;</span>
</code></pre></div><p>For more info, visit the <ahref="/SpotifyAPI-NET/auth/getting_started/">Getting Started of SpotifyAPI.Web.Auth</a></p><hr><h2id="examples"><ahref="#examples"aria-hidden="true"class="header-anchor">#</a> Examples</h2><p>A list of small examples can be found <ahref="/SpotifyAPI-NET/web/examples/">here</a>. Do you think a specific example is missing? Feel free to open a PR.mdIssue!</p><hr><h2id="error-handling"><ahref="#error-handling"aria-hidden="true"class="header-anchor">#</a> Error-Handling</h2><p>Every API-Call returns a reponse-model which consists of base-error model. To check if a specific API-Call was successful, use the following approach:</p><divclass="language-csharp extra-class"><preclass="language-csharp"><code><spanclass="token class-name">PrivateProfile</span> profile <spanclass="token operator">=</span> _spotify<spanclass="token punctuation">.</span><spanclass="token function">GetPrivateProfile</span><spanclass="token punctuation">(</span><spanclass="token punctuation">)</span><spanclass="token punctuation">;</span>
</code></pre></div><p>In case some or all of the returned values are null, consult error status and message, they can lead to an explanation!</p><h2id="sync-vs-asynchronous"><ahref="#sync-vs-asynchronous"aria-hidden="true"class="header-anchor">#</a> Sync vs Asynchronous</h2><p>Every API-Call has an <code>asynchronous</code> and <code>synchronous</code> method.</p><divclass="language-csharp extra-class"><preclass="language-csharp"><code><spanclass="token keyword">public</span><spanclass="token keyword">async</span><spanclass="token keyword">void</span><spanclass="token function">Test</span><spanclass="token punctuation">(</span><spanclass="token punctuation">)</span>
</code></pre></div><p>Note that the <code>synchronous</code> call will block the current Thread!</p><hr><h2id="api-reference"><ahref="#api-reference"aria-hidden="true"class="header-anchor">#</a> API-Reference</h2><h3id="albums"><ahref="#albums"aria-hidden="true"class="header-anchor">#</a> Albums</h3><ul><li><ahref="/SpotifyAPI-NET/web/albums.html#getalbumtracks">GetAlbumTracks</a></li><li><ahref="/SpotifyAPI-NET/web/albums.html#getalbum">GetAlbum</a></li><li><ahref="/SpotifyAPI-NET/web/albums.html#getseveralalbums">GetSeveralAlbums</a></li></ul><h3id="artists"><ahref="#artists"aria-hidden="true"class="header-anchor">#</a> Artists</h3><ul><li><ahref="/SpotifyAPI-NET/web/artists.html#getartist">GetArtist</a></li><li><ahref="/SpotifyAPI-NET/web/artists.html#getrelatedartists">GetRelatedArtists</a></li><li><ahref="/SpotifyAPI-NET/web/artists.html#getartiststoptracks">GetArtistsTopTracks</a></li><li><ahref="/SpotifyAPI-NET/web/artists.html#getartistsalbums">GetArtistsAlbums</a></li><li><ahref="/SpotifyAPI-NET/web/artists.html#getseveralartists">GetSeveralArtists</a></li></ul><h3id="browse"><ahref="#browse"aria-hidden="true"class="header-anchor">#</a> Browse</h3><ul><li><ahref="/SpotifyAPI-NET/web/browse.html#getfeaturedplaylists">GetFeaturedPlaylists</a></li><li><ahref="/SpotifyAPI-NET/web/browse.html#getnewalbumreleases">GetNewAlbumReleases</a></li><li><ahref="/SpotifyAPI-NET/web/browse.html#getcategories">GetCategories</a></li><li><ahref="/SpotifyAPI-NET/web/browse.html#getcategory">GetCategory</a></li><li><ahref="/SpotifyAPI-NET/web/browse.html#getcategoryplaylists">GetCategoryPlaylists</a></li></ul><h3id="follow"><ahref="#follow"aria-hidden="true"class="header-anchor">#</a> Follow</h3><ul><li><ahref="/SpotifyAPI-NET/web/follow.html#follow">Follow</a></li><li><ahref="/SpotifyAPI-NET/web/follow.html#unfollow">Unfollow</a></li><li><ahref="/SpotifyAPI-NET/web/follow.html#isfollowing">IsFollowing</a></li><li><ahref="/SpotifyAPI-NET/web/follow.html#followplaylist">FollowPlaylist</a></li><li><ahref="/SpotifyAPI-NET/web/follow.html#unfollowplaylist">UnfollowPlaylist</a></li><li><ahref="/SpotifyAPI-NET/web/follow.html#isfollowingplaylist">IsFollowingPlaylist</a></li></ul><h3id="library"><ahref="#library"aria-hidden="true"class="header-anchor">#</a> Library</h3><ul><li><ahref="/SpotifyAPI-NET/web/library.html#savetracks">SaveTracks</a></li><li><ahref="/SpotifyAPI-NET/web/library.html#savetrack">SaveTrack</a></li><li><ahref="/SpotifyAPI-NET/web/library.html#getsavedtracks">GetSavedTracks</a></li><li><ahref="/SpotifyAPI-NET/web/library.html#removesavedtracks">RemoveSavedTracks</a></li><li><ahref="/SpotifyAPI-NET/web/library.html#checksavedtracks">CheckSavedTracks</a></li><li><ahref="/SpotifyAPI-NET/web/library.html#savealbums">SaveAlbums</a></li><li><ahref="/SpotifyAPI-NET/web/library.html#savealbum">SaveAlbum</a></li><li><ahref="/SpotifyAPI-NET/web/library.html#getsavedalbums">GetSavedAlbums</a></li><li><ahref="/SpotifyAPI-NET/web/library.html#removesavedalbums">RemoveSavedAlbums</a></li><li><ahref="/SpotifyAPI-NET/web/library.html#checksavedalbums">CheckSavedAlbums</a></li></ul><h3id="personalization"><ahref="#personalization"aria-hidden="true"class="header-anchor">#</a> Personalization</h3><ul><li><ahref="/SpotifyAPI-NET/web/personalization.html#getuserstoptracks">GetUsersTopTracks</a></li><li><ahref="/SpotifyAPI-NET/web/personalization.html#getuserstopartists">GetUsersTopArtists</a></li><li><ahref="/SpotifyAPI-NET/web/personalization.html#getusersrecentlyplayedtracks">GetUsersRecentlyPlayedTracks</a></li></ul><h3id="player"><ahref="#player"aria-hidden="true"class="header-anchor">#</a> Player</h3><ul><li><ahref="/SpotifyAPI-NET/web/player.html#getdevices">GetDevices</a></li><li><ahref="/SpotifyAPI-NET/web/player.html#getplayback">GetPlayback</a></li><li><ahref="/SpotifyAPI-NET/web/player.html#getplayingtrack">GetPlayingTrack</a></li><li><ahref="/SpotifyAPI-NET/web/player.html#transferplayback">TransferPlayback</a></li>