Skip to main content

Spotify Connector for Podcast Data

Project description

Spotify Connector

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.

Installation

pip install spotifyconnector

Usage as a library

from spotifyconnector import SpotifyConnector

# Set up the connector
connector = SpotifyConnector(
    client_id="your_client_id",
    client_secret="your_client_secret",
    redirect_uri="your_redirect_uri",
    refresh_token="your_refresh_token",
)

# 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 Pipenv for virtualenv and dev dependency management. With Pipenv installed:

  1. Install your locally checked out code in development mode, including its dependencies, and all dev dependencies into a virtual environment:
pipenv sync --dev
  1. Create an environment file and fill in the required values:
cp .env.example .env
  1. Run the script in the virtual environment, which will automatically load your .env:
pipenv run spotifyconnector

To add a new dependency for use during the development of this library:

pipenv install --dev $package

To add a new dependency necessary for the correct operation of this library, add the package to the install_requires section of ./setup.py, then:

pipenv install

To publish the package:

python setup.py sdist bdist_wheel
twine upload dist/*

or

make publish

Credits

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spotifyconnector-0.8.1.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

spotifyconnector-0.8.1-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file spotifyconnector-0.8.1.tar.gz.

File metadata

  • Download URL: spotifyconnector-0.8.1.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.18

File hashes

Hashes for spotifyconnector-0.8.1.tar.gz
Algorithm Hash digest
SHA256 b8a2eb8ce49b3cff4bc8fc045194604ea5a715a147cf4d03ace780160f42ee15
MD5 1aa54acd0a7cba6330c009c971376e5c
BLAKE2b-256 eeb606e3b0f4d7c9a9505c0e11ecda696e30ac6d33c829b2d263d5273573ae6a

See more details on using hashes here.

File details

Details for the file spotifyconnector-0.8.1-py3-none-any.whl.

File metadata

File hashes

Hashes for spotifyconnector-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5c5fecf5f187be2b3b5b209b5bd131155890aa806967dd6914bed31ef9c86887
MD5 4dc4faf709f2c69ae8d04e6508249523
BLAKE2b-256 0e5427b91b05bd344b902a090345d31211dcc1ebca9a59ade3f780ca825f3a6d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page