Skip to content

Commit

Permalink
Merge branch 'master' into retry-warning
Browse files Browse the repository at this point in the history
  • Loading branch information
dieser-niko authored Jun 25, 2024
2 parents ed3ba19 + 5e09c78 commit 6cef6b6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- Added custom `urllib3.Retry` class for printing a warning when a rate/request limit is reached.

### Fixed
Expand Down
24 changes: 23 additions & 1 deletion FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
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`

0 comments on commit 6cef6b6

Please sign in to comment.