<titledata-react-helmet="true">Retry Handling | SpotifyAPI-NET</title><metadata-react-helmet="true"property="og:url"content="https://johnnycrazy.github.io/SpotifyAPI-NET/docs/retry_handling"><metadata-react-helmet="true"name="docusaurus_locale"content="en"><metadata-react-helmet="true"name="docusaurus_version"content="current"><metadata-react-helmet="true"name="docusaurus_tag"content="docs-default-current"><metadata-react-helmet="true"property="og:title"content="Retry Handling | SpotifyAPI-NET"><metadata-react-helmet="true"name="description"content="In Error Handling, we already found out that requests can fail. We provide a way to automatically retry requests via retry handlers. Note that, by default, no retries are performed."><metadata-react-helmet="true"property="og:description"content="In Error Handling, we already found out that requests can fail. We provide a way to automatically retry requests via retry handlers. Note that, by default, no retries are performed."><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/retry_handling"><linkdata-react-helmet="true"rel="alternate"href="https://johnnycrazy.github.io/SpotifyAPI-NET/docs/retry_handling"hreflang="en"><linkdata-react-helmet="true"rel="alternate"href="https://johnnycrazy.github.io/SpotifyAPI-NET/docs/retry_handling"hreflang="x-default"><linkrel="stylesheet"href="/SpotifyAPI-NET/assets/css/styles.834af7f3.css">
</span></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> // use retry as often as you want, make sure to return a response</span></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> }</span></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain">}</span></span></code></pre><buttontype="button"aria-label="Copy code to clipboard"class="copyButton_Ue-o clean-btn">Copy</button></div></div><h2><aaria-hidden="true"tabindex="-1"class="anchor enhancedAnchor_2LWZ"id="simpleretryhandler"></a>SimpleRetryHandler<aclass="hash-link"href="#simpleretryhandler"title="Direct link to heading">#</a></h2><p>A <code>SimpleRetryHandler</code> is included, which contains the following retry logic:</p><ul><li>Retries the (configurable) status codes: 500, 502, 503 and 429.</li><li><code>RetryAfter</code> - Specifies the delay between retried calls.</li><li><code>RetryTimes</code> - Specifies the maxiumum amount of performed retries per call.</li><li><code>TooManyRequestsConsumesARetry</code> - Whether a failure of type "Too Many Requests" should use up one of the retry attempts.</li></ul><divclass="codeBlockContainer_K1bP"><divclass="codeBlockContent_hGly csharp"><pretabindex="0"class="prism-code language-csharp codeBlock_23N8 thin-scrollbar"style="color:#bfc7d5;background-color:#292d3e"><codeclass="codeBlockLines_39YC"><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain">var config = SpotifyClientConfig</span></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> .CreateDefault()</span></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> .WithRetryHandler(new SimpleRetryHandler() { RetryAfter = TimeSpan.FromSeconds(1) });</span></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"style="display:inline-block">