<titledata-react-helmet="true">Getting Started | SpotifyAPI-NET</title><metadata-react-helmet="true"name="docsearch:version"content="5.1.1"><metadata-react-helmet="true"name="twitter:card"content="summary_large_image"><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."><metadata-react-helmet="true"property="og:url"content="https://johnnycrazy.github.io/SpotifyAPI-NET//docs/web/getting_started"><linkdata-react-helmet="true"rel="shortcut icon"href="/img/favicon.ico"><linkdata-react-helmet="true"rel="canonical"href="https://johnnycrazy.github.io/SpotifyAPI-NET//docs/web/getting_started"><linkrel="stylesheet"href="/styles.8a053330.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_ZqCz"id="first-steps"></a>First steps<aaria-hidden="true"tabindex="-1"class="hash-link"href="#first-steps"title="Direct link to heading">#</a></h2><h3><aaria-hidden="true"tabindex="-1"class="anchor enhancedAnchor_ZqCz"id="imports"></a>Imports<aaria-hidden="true"tabindex="-1"class="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="mdxCodeBlock_iHAB"><divclass="codeBlockContent_32p_"><buttontype="button"aria-label="Copy code to clipboard"class="copyButton_1BYj">Copy</button><divtabindex="0"class="prism-code language-csharp codeBlock_19pQ"><divclass="codeBlockLines_2n9r"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></div></div><h3><aaria-hidden="true"tabindex="-1"class="anchor enhancedAnchor_ZqCz"id="basic-usage"></a>Basic-Usage<aaria-hidden="true"tabindex="-1"class="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="mdxCodeBlock_iHAB"><divclass="codeBlockContent_32p_"><buttontype="button"aria-label="Copy code to clipboard"class="copyButton_1BYj">Copy</button><divtabindex="0"class="prism-code language-csharp codeBlock_19pQ"><divclass="codeBlockLines_2n9r"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></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="mdxCodeBlock_iHAB"><divclass="codeBlockContent_32p_"><buttontype="button"aria-label="Copy code to clipboard"class="copyButton_1BYj">Copy</button><divtabindex="0"class="prism-code language-csharp codeBlock_19pQ"><divclass="codeBlockLines_2n9r"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></div></div><p>For more info, visit the <ahref="/auth/getting_started/">Getting Started of SpotifyAPI.Web.Auth</a></p><h2><aaria-hidden="true"tabindex="-1"class="anchor enhancedAnchor_ZqCz"id="error-handling"></a>Error-Handling<aaria-hidden="true"tabindex="-1"class="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="mdxCodeBlock_iHAB"><divclass="codeBlockContent_32p_"><buttontype="button"aria-label="Copy code to clipboard"class="copyButton_1BYj">Copy</button><divtabindex="0"class="prism-code language-csharp codeBlock_19pQ"><divclass="codeBlockLines_2n9r"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"><spanclass="token plain"> Console.WriteLine(&