From 5e09c78ccf9cb5450da50e5a984e21cce39ee7a2 Mon Sep 17 00:00:00 2001 From: Niko Date: Mon, 24 Jun 2024 23:43:54 +0200 Subject: [PATCH] Added an explanation for rate/request limits to FAQ (#1133) --- CHANGELOG.md | 1 + FAQ.md | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 715b815..6769291 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Add your changes below. - Updated order of instructions for Python and pip package manager installation in TUTORIAL.md - Updated TUTORIAL.md instructions to match current layout of Spotify Developer Dashboard - Added test_artist_id, test_artist_url, and test_artists_mixed_ids to non_user_endpoints test.py +- Added rate/request limit to FAQ ### Fixed - Audiobook integration tests diff --git a/FAQ.md b/FAQ.md index 63fa052..f34fa19 100644 --- a/FAQ.md +++ b/FAQ.md @@ -51,4 +51,26 @@ must be specified: `search("abba", market="DE")`. If you cannot open a browser, set `open_browser=False` when instantiating SpotifyOAuth or SpotifyPKCE. You will be prompted to open the authorization URI manually. -See the [headless auth example](examples/headless.py). \ No newline at end of file +See the [headless auth example](examples/headless.py). + +### My application is not responding + +This is still speculation, but it seems that Spotify has two limits. A rate limit and a request limit. + +- The rate limit prevents a script from requesting too much from the API in a short period of time. +- The request limit limits how many requests you can make in a 24 hour window. +The limits appear to be endpoint-specific, so each endpoint has its own limits. + +If your application stops responding, it's likely that you've reached the request limit. +There's nothing Spotipy can do to prevent this, but you can follow Spotify's [Rate Limits](https://developer.spotify.com/documentation/web-api/concepts/rate-limits) guide to learn how rate limiting works and what you can do to avoid ever hitting a limit. + +#### *Why* is the application not responding? +Spotipy (or more precisely `urllib3`) has a backoff-retry strategy built in, which is waiting until the rate limit is gone. +If you want to receive an error instead, then you can pass `retries=0` to `Spotify` like this: +```python +sp = spotipy.Spotify( + retries=0, + ... +) +``` +The error raised is a `spotipy.exceptions.SpotifyException`