Skip to main content

Spotify Connector

Docs

OpenPodcast Banner

This is a simple library for connecting to the unofficial Spotify podcast API.
It can be used to export data from your dashboard at https://podcasters.spotify.com/home.

Supported Data

  • List of episodes
  • Starts and streams
  • Listeners
  • Followers
  • Gender
  • Age
  • Country
  • Episode performance

Credentials

Before you can use the library, you must extract your Spotify credentials from the dashboard; they are not exposed through your Spotify settings.

You can use our web extension for that or take a look at the code to see how to do it manually.

You need three values:

  • sp_dc: Can be found in the Spotify cookies once you're logged in. It's a long string with around 160 characters.
  • sp_key: Can also be found in the Spotify cookies once you're logged in. It's a UUID (36 characters).
  • client_id: This is a static value and stays the same for everyone. It is 05a1371ee5194c27860b3ff3ff3979d2. Spotify might change it in the future, so if you run into issues, please check your network requests while logged in to find the new value.

Installation

pip install spotifyconnector

Usage as a library

from spotifyconnector import SpotifyConnector

# Set up the connector
connector = SpotifyConnector(
    base_url="https://generic.wg.spotify.com/podcasters/v0123"
    client_id="05a1371ee5194c27860b3ff3ff3979d2", # login to spotify and monitor connection to get this id
    podcast_id="your_spotify_podcast_id",
    sp_dc="xxxxxxxxxxxxxxxxxx...xxx", # can be found in cookies after logged in (long string)
    sp_key="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # can be found in cookies after logged in
)

# Get podcast metadata
connector.metadata()

# Get the list of listeners of a podcast
listeners = connector.listeners()

# Get the aggregated listeners of a podcast (by age, country, gender)
aggregate = connector.aggregate()

# Iterate over all episodes (supports pagination)
for episode in connector.episodes():
    # Do something with episode
    pass

# Get the performance of an episode
performance = connector.performance("episode_id")

# ...

See __main.py__ for all endpoints.

Local Testing

You can run the script locally to test it:

make dev

To run the script with verbose logging:

export LOGURU_LEVEL=TRACE
make dev

Development

We use uv for virtualenv and dependency management. With uv installed:

  1. Install your locally checked-out code in editable mode, including all runtime, optional, and dev dependencies into a .venv/ virtual environment:
uv sync --all-extras --group dev

Or simply:

make install
  1. Create an environment file and fill in the required values:
cp .env.example .env
  1. Run the script in the virtual environment:
uv run spotifyconnector

To add a new runtime dependency:

uv add $package

To add a new development-only dependency:

uv add --group dev $package

To build the package locally (sdist + wheel into dist/):

uv build

Releasing

Releases are published to PyPI automatically by GitHub Actions when a new GitHub release is created.

  1. Bump the version field in pyproject.toml.
  2. Commit the bump and open a PR; merge it once CI is green.
  3. Create a new GitHub release with a tag like v0.8.3 matching the version in pyproject.toml. The Deploy workflow will build with uv build and publish via twine using the PYPI_API_TOKEN secret.

Credits

This was inspired by the code at wdr-okr, extended and released to PyPi.

Release files for spotifyconnector 0.8.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spotifyconnector 0.8.3
File Size Uploaded
spotifyconnector-0.8.3.tar.gz 153.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spotifyconnector 0.8.3
File Interpreter ABI Platform
spotifyconnector-0.8.3-py3-none-any.whl Python 3 none any Details

Total release size:163.8 kB

Release files / spotifyconnector-0.8.3.tar.gz

Download URL spotifyconnector-0.8.3.tar.gz
Size 153.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b8401d2b093de14277a466caa82b96e7361411e802ac0f0e5ebda60bca36e618
BLAKE2b-256 checksum
How to use checksums
a57db50e19a8efa3a1f5e1e207c066badf51e4874cb87aa051299f2ac89efcaf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / spotifyconnector-0.8.3-py3-none-any.whl

Download URL spotifyconnector-0.8.3-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1b7502ae27f85d249ad7c6cce99863bf5e07ac4d477fa95fc34391e13c10bd42
BLAKE2b-256 checksum
How to use checksums
bc8053cb8d35f35431fb3fb3c726e77a4db84067a88f27abc0025a807fbc5369
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

0.8.3 This release

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page