Skip to main content

A Python package for interacting with the Soundcharts API.

Project description

Soundcharts Module

A Python package for interacting with the Soundcharts API.

API Documentation

Full documentation of the API is available here: Soundcharts API Documentation

You will need a Soundcharts API subscription to use this package.

Features

  • Easily pull data from Soundcharts' API.
  • Every endpoint from the documentation is available as a Python function.
    • For example, the "get audience" endpoint in the "playlist" category is accessible via playlist.get_audience().
  • Synchronous and Asynchronous support.
  • Automatically loops through endpoints to get around API limitations, such as the limit of 100 items per request.
  • Configurable error handling.

Installation

pip install soundcharts

Usage

Synchronous Client

Best for standard scripts, Jupyter notebooks, or scheduled cron jobs.

from soundcharts import SoundchartsClient

sc = SoundchartsClient(app_id="your_app_id", api_key="your_api_key")

# Example with Billie Eilish's UUID
billie_metadata = sc.artist.get_artist_metadata("11e81bcc-9c1c-ce38-b96b-a0369fe50396")
print(billie_metadata)

Asynchronous Client

Recommended for high-performance applications, FastAPI, or when integrating with other asyncio libraries. This avoids blocking the event loop and allows for faster execution in concurrent environments.

import asyncio
from soundcharts import SoundchartsClientAsync

async def main():
    sc = SoundchartsClientAsync(app_id="your_app_id", api_key="your_api_key")

    # Use 'await' for all API calls
    billie_uuid = "11e81bcc-9c1c-ce38-b96b-a0369fe50396"
    billie_metadata = await sc.artist.get_artist_metadata(billie_uuid)
    print(billie_metadata)

asyncio.run(main())

Error handling

You can set the severity of the console logs, file logs, and exceptions:

from soundcharts.client import SoundchartsClient
import logging

sc = SoundchartsClient( app_id="your_app_id",
                        api_key="your_api_key",
                        console_log_level=logging.INFO,
                        file_log_level=logging.WARNING,
                        exception_log_level=logging.ERROR)

Setting the level of the console or file log to logging.DEBUG will log each request send to the API.

Parallel processing

You can specify the number of requests to run in parallel. It's especially useful when looping through a lot of calls, like in this case fetching 3 months of Billie Eilish's radio airplay (about 3,000 calls):

from soundcharts.client import SoundchartsClient
import logging

sc = SoundchartsClient( app_id="your_app_id",
                        api_key="your_api_key",
                        parallel_requests=10)

billie = "11e81bcc-9c1c-ce38-b96b-a0369fe50396"

response = sc.artist.get_radio_spins(
    billie, start_date="2025-01-01", end_date="2025-03-31", limit=None
)

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

soundcharts-1.0.1.tar.gz (35.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

soundcharts-1.0.1-py3-none-any.whl (44.2 kB view details)

Uploaded Python 3

File details

Details for the file soundcharts-1.0.1.tar.gz.

File metadata

  • Download URL: soundcharts-1.0.1.tar.gz
  • Upload date:
  • Size: 35.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for soundcharts-1.0.1.tar.gz
Algorithm Hash digest
SHA256 2597d79ce2094e7a2da5dd51a573ea243bda8f869e5cce902f93516ae8cfc9b9
MD5 81e9f40faa06f9a01202c6c74b2fedcb
BLAKE2b-256 96a9208d8d033f11cf6bb21b5935e2b733834a898e83175a9f3f807ecb6dea27

See more details on using hashes here.

File details

Details for the file soundcharts-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: soundcharts-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 44.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for soundcharts-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3f11a94f28385f2767b704ac92869576921663168e57d6f74e7a1615d97a156b
MD5 e9b0ca917f6a3815b6e445dde41b6703
BLAKE2b-256 f18a9e70410c66f39dec570a9d48ba1ce253f01d97c642404a13e04e2a9bb6c3

See more details on using hashes here.

Supported by

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