<titledata-react-helmet="true">Configuration | SpotifyAPI-NET</title><metadata-react-helmet="true"name="docsearch:version"content="next"><metadata-react-helmet="true"name="twitter:card"content="summary_large_image"><metadata-react-helmet="true"property="og:title"content="Configuration | SpotifyAPI-NET"><metadata-react-helmet="true"name="description"content="To configure the spotify client functionality, the SpotifyClientConfig class exists."><metadata-react-helmet="true"property="og:description"content="To configure the spotify client functionality, the SpotifyClientConfig class exists."><metadata-react-helmet="true"property="og:url"content="https://johnnycrazy.github.io/SpotifyAPI-NET/docs/next/configuration"><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/next/configuration"><linkrel="stylesheet"href="/SpotifyAPI-NET/styles.8a053330.css">
</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">// is the same as</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">var spotify = new SpotifyClient("YourAccessToken");</span></div></div></div></div></div><p>We won't cover every possible configuration in this part, head over to the specific guides for that:</p><ul><li>...</li></ul><h2><aaria-hidden="true"tabindex="-1"class="anchor enhancedAnchor_ZqCz"id="httpclient-notes"></a>HTTPClient Notes<aaria-hidden="true"tabindex="-1"class="hash-link"href="#httpclient-notes"title="Direct link to heading">#</a></h2><p>One important part of the configuration is the used HTTPClient. By default, every time when a <code>SpotifyClientConfig</code> is instantiated, a new <code>HTTPClient</code> is created in the background. For Web Applications which require a lot of different configs due to user based access tokens, it is <strong>not</strong> advised to create a new config from scratch with every HTTP call. Instead, a default (static) config should be used to create a new config with a new access token.</p><p>Consider the following HTTP Endpoint:</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">public HttpResult Get()</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">{</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> var config = SpotifyClientConfig.CreateDefault("YourAccessToken")</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> var spotify = new SpotifyClient(config);</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">}</span></div></div></div></div></div><p>This creates a new <code>HTTPClient</code> every time a request is made, which can be quite bad for the performance. Instead we should use a base config and use <code>WithToken</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">// somewhere global/static</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">public static SpotifyClientConfig DefaultConfig = SpotifyClientConfig.CreateDefault();</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"style="display:inline-block">