No description
Find a file
2026-03-24 15:16:48 +05:30
.github Delete FUNDING.yml 2023-10-25 11:01:09 +09:00
dev Release 0.0.1 2022-02-09 20:55:27 +09:00
docs Release 0.0.1 2022-02-09 20:55:27 +09:00
examples change all request.headers from dicts to CaseInsensitiveDicts 2025-10-19 17:00:58 -05:00
img [ImgBot] Optimize images 2021-07-20 09:17:00 +00:00
librespot Fixed proto not defined 2026-03-24 15:16:48 +05:30
librespot_player change all request.headers from dicts to CaseInsensitiveDicts 2025-10-19 17:00:58 -05:00
proto feat: add FLAC lossless format support and refactor quality pickers (while staying backward compatible) 2025-10-10 20:08:41 -04:00
.deepsource.toml Add .deepsource.toml 2021-04-09 23:15:34 +00:00
.gitignore Add player state 2021-02-25 18:22:28 +09:00
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md 2021-04-06 07:11:20 +09:00
LICENSE.txt Add LICENSE.txt 2021-05-15 09:04:41 +09:00
README.md Support Rust librespot credential format in stored_file() 2025-09-30 18:42:33 +02:00
requirements.txt Update requirements.txt 2025-11-07 21:48:47 +05:30
SECURITY.md Restyled by prettier-markdown 2021-05-22 01:26:37 +00:00
setup.py Bump version 2023-05-17 07:00:11 +09:00
sider.yml Restyled by prettier-yaml 2021-04-09 23:04:49 +00:00

License Stars Forks DeepSource

Counter

Librespot-Python

Open Source Spotify Client

Support Project

If you find our project useful and want to support its development, please consider making a donation. Your contribution will help us maintain and improve the project, ensuring that it remains free and accessible to everyone.

GitHub Sponsor Liberapay receiving

About The Project

This project was developed to make the music streaming service Spotify available on any device.

Attention!

This repository has been completely rewritten from the transplant.
There may be some functions that are not implemented yet.
If so, please feel free to open an issue.

Note

It is still in the idea stage, so there is a possibility of unintended behavior or major specification changes.
We DO NOT encourage piracy and DO NOT support any form of downloader/recorder designed with the help of this repository and in general anything that goes against the Spotify ToS.
For other guidelines, please see CODE_OF_CONDUCT.md.

Getting Started

Prerequisites

Installation

Stable Version

pip install librespot

Snapshot Version *Recommended

pip install git+https://github.com/kokarare1212/librespot-python

Usage

Use Zeroconf for Login

from librespot.zeroconf import ZeroconfServer

zeroconf = ZeroconfServer.Builder().create()

Use OAuth for Login

Without auth url callback

from librespot.core import Session

# This will log an url in the terminal that you have to open

session = Session.Builder() \
    .oauth(None) \
    .create()

With auth url callback

from librespot.core import Session

# This will pass the auth url to the method

def auth_url_callback(url):
    print(url)

session = Session.Builder() \
    .oauth(auth_url_callback) \
    .create()

Use Stored Credentials for Login

from librespot.core import Session

# Supports both Python and Rust librespot credential formats

session = Session.Builder() \
    .stored_file("/path/to/credentials.json") \
    .create()

Get Spotify's OAuth token

from librespot.core import Session


session = Session.Builder() \
    .oauth(None) \
    .create()

access_token = session.tokens().get("playlist-read")

Get Music Stream

*Currently, music streaming is supported, but it may cause unintended behavior.

from librespot.core import Session
from librespot.metadata import TrackId
from librespot.audio.decoders import AudioQuality, VorbisOnlyAudioQuality

session = Session.Builder() \
    .oauth(None) \
    .create()

track_id = TrackId.from_uri("spotify:track:xxxxxxxxxxxxxxxxxxxxxx")
stream = session.content_feeder().load(track_id, VorbisOnlyAudioQuality(AudioQuality.VERY_HIGH), False, None)
# stream.input_stream.stream().read() to get one byte of the music stream.

Other uses are examples or read this document for detailed specifications.

Debug

To display the debug information, you need to inject the following code at the top of the code.

import logging


logging.basicConfig(level=logging.DEBUG)

Contributing

Pull requests are welcome.

License

Distributed under the Apache-2.0 License. See LICENSE.txt for more information.