<linkrel="alternate"type="application/rss+xml"href="/SpotifyAPI-NET/news/rss.xml"title="SpotifyAPI-NET Blog RSS Feed">
<linkrel="alternate"type="application/atom+xml"href="/SpotifyAPI-NET/news/atom.xml"title="SpotifyAPI-NET Blog Atom Feed"><titledata-react-helmet="true">Getting Started | SpotifyAPI-NET</title><metadata-react-helmet="true"property="og:url"content="https://johnnycrazy.github.io/SpotifyAPI-NET/docs/5.1.1/web/getting_started"><metadata-react-helmet="true"name="docusaurus_locale"content="en"><metadata-react-helmet="true"name="docusaurus_version"content="5.1.1"><metadata-react-helmet="true"name="docusaurus_tag"content="docs-default-5.1.1"><metadata-react-helmet="true"property="og:title"content="Getting Started | SpotifyAPI-NET"><metadata-react-helmet="true"name="description"content="This API provides full access to the new SpotifyWebAPI introduced here."><metadata-react-helmet="true"property="og:description"content="This API provides full access to the new SpotifyWebAPI introduced here."><linkdata-react-helmet="true"rel="shortcut icon"href="/SpotifyAPI-NET/img/favicon.ico"><linkdata-react-helmet="true"rel="canonical"href="https://johnnycrazy.github.io/SpotifyAPI-NET/docs/5.1.1/web/getting_started"><linkdata-react-helmet="true"rel="alternate"href="https://johnnycrazy.github.io/SpotifyAPI-NET/docs/5.1.1/web/getting_started"hreflang="en"><linkdata-react-helmet="true"rel="alternate"href="https://johnnycrazy.github.io/SpotifyAPI-NET/docs/5.1.1/web/getting_started"hreflang="x-default"><linkrel="stylesheet"href="/SpotifyAPI-NET/assets/css/styles.fa980c59.css">
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><h2><aaria-hidden="true"tabindex="-1"class="anchor enhancedAnchor_2LWZ"id="first-steps"></a>First steps<aclass="hash-link"href="#first-steps"title="Direct link to heading">#</a></h2><h3><aaria-hidden="true"tabindex="-1"class="anchor enhancedAnchor_2LWZ"id="imports"></a>Imports<aclass="hash-link"href="#imports"title="Direct link to heading">#</a></h3><p>So after you added the API to your project, you may want to add following imports to your files:</p><divclass="codeBlockContainer_K1bP"><divclass="codeBlockContent_hGly csharp"><divtabindex="0"class="prism-code language-csharp codeBlock_23N8 thin-scrollbar"><divclass="codeBlockLines_39YC"style="color:#bfc7d5;background-color:#292d3e"><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">using SpotifyAPI.Web; //Base Namespace</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">using SpotifyAPI.Web.Enums; //Enums</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">using SpotifyAPI.Web.Models; //Models for the JSON-responses</span></div></div></div><buttontype="button"aria-label="Copy code to clipboard"class="copyButton_Ue-o">Copy</button></div></div><h3><aaria-hidden="true"tabindex="-1"class="anchor enhancedAnchor_2LWZ"id="basic-usage"></a>Basic-Usage<aclass="hash-link"href="#basic-usage"title="Direct link to heading">#</a></h3><p>Now you can actually start doing calls to the SpotifyAPI, just create a new Instance of SpotifyWebAPI:</p><divclass="codeBlockContainer_K1bP"><divclass="codeBlockContent_hGly csharp"><divtabindex="0"class="prism-code language-csharp codeBlock_23N8 thin-scrollbar"><divclass="codeBlockLines_39YC"style="color:#bfc7d5;background-color:#292d3e"><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">private static SpotifyWebAPI _spotify;</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"style="display:inline-block">
</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">public static void Main(String[] args)</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">{</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> _spotify = new SpotifyWebAPI()</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> {</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> AccessToken = "XXXXXXXXXXXX",</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> TokenType = "Bearer"</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> }</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> FullTrack track = _spotify.GetTrack("3Hvu1pq89D4R0lyPBoujSv");</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> Console.WriteLine(track.Name); //Yeay! We just printed a tracks name.</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">}</span></div></div></div><buttontype="button"aria-label="Copy code to clipboard"class="copyButton_Ue-o">Copy</button></div></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="codeBlockContainer_K1bP"><divclass="codeBlockContent_hGly csharp"><divtabindex="0"class="prism-code language-csharp codeBlock_23N8 thin-scrollbar"><divclass="codeBlockLines_39YC"style="color:#bfc7d5;background-color:#292d3e"><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">CredentialsAuth auth = new CredentialsAuth("YourClientID", "YourClientSecret");</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">Token token = await auth.GetToken();</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">_spotify = new SpotifyWebAPI()</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">{</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> AccessToken = token.AccessToken,</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> TokenType = token.TokenType</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">}</span></div></div></div><buttontype="button"aria-label="Copy code to clipboard"class="copyButton_Ue-o">Copy</button></div></div><p>For more info, visit the <ahref="/SpotifyAPI-NET/docs/5.1.1/auth/getting_started">Getting Started of SpotifyAPI.Web.Auth</a></p><h2><aaria-hidden="true"tabindex="-1"class="anchor enhancedAnchor_2LWZ"id="error-handling"></a>Error-Handling<aclass="hash-link"href="#error-handling"title="Direct link to heading">#</a></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="codeBlockContainer_K1bP"><divclass="codeBlockContent_hGly csharp"><divtabindex="0"class="prism-code language-csharp codeBlock_23N8 thin-scrollbar"><divclass="codeBlockLines_39YC"style="color:#bfc7d5;background-color:#292d3e"><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">PrivateProfile profile = _spotify.GetPrivateProfile();</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">if (profile.HasError())</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">{</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> Console.WriteLine("Error Status: " + profile.Error.Status);</span></div><divclass="token-line"style="color:#bfc7d5"