Skip to main content

A sleek API wrapper for Spotify's private API

Project description

Legal Notice

Disclaimer: This repository and any associated code are provided "as is" without warranty of any kind, either expressed or implied. The author of this repository does not accept any responsibility for the use or misuse of this repository or its contents. The author does not endorse any actions or consequences arising from the use of this repository. Any copies, forks, or re-uploads made by other users are not the responsibility of the author. The repository is solely intended as a Proof Of Concept for educational purposes regarding the use of a service's private API. By using this repository, you acknowledge that the author makes no claims about the accuracy, legality, or safety of the code and accepts no liability for any issues that may arise. More information can be found HERE.

SpotAPI

Welcome to SpotAPI! This Python library is designed to interact with the private and public Spotify APIs, emulating the requests typically made through a web browser. This wrapper provides a convenient way to access Spotify’s rich set of features programmatically.

Note: This project is intended solely for educational purposes and should be used responsibly. Accessing private endpoints and scraping data without proper authorization may violate Spotify's terms of service.

Table of Contents

  1. Introduction
  2. Features
  3. Docs
  4. Installation
  5. Quick Examples
  6. Import Cookies
  7. Contributing
  8. License
  9. Extended Functionality & Private Modules

Features

  • No Premium Required: Unlike the Web API which requires Spotify Premium, SpotAPI requires no Spotify Premium at all!
  • Public API Access: Retrieve and manipulate public Spotify data such as playlists, albums, and tracks with ease.
  • Private API Access: Explore private Spotify endpoints to tailor your application to your needs.
  • Ready to Use: SpotAPI is designed for immediate integration, allowing you to accomplish tasks with just a few lines of code.
  • No API Key Required: Seamlessly use SpotAPI without needing a Spotify API key. It's straightforward and hassle free!
  • Browser-like Requests: Accurately replicate the HTTP requests Spotify makes in the browser, providing a true to web experience while remaining undetected.
  • Multi-Language Support: Set your preferred language for API responses using ISO 639-1 language codes (e.g., 'ko', 'ja', 'zh', 'en').

Everything you can do with Spotify, SpotAPI can do with just a user’s login credentials.

Docs

Installation

pip install spotapi

Quick Examples

With User Authentication

from spotapi import (
    Login, 
    Config, 
    NoopLogger, 
    solver_clients, 
    PrivatePlaylist, 
    MongoSaver
)

cfg = Config(
    solver=solver_clients.Capsolver("YOUR_API_KEY", proxy="YOUR_PROXY"), # Proxy is optional
    logger=NoopLogger(),
    # You can add a proxy by passing a custom TLSClient
)

instance = Login(cfg, "YOUR_PASSWORD", email="YOUR_EMAIL")
# Now we have a valid Login instance to pass around
instance.login()

# Do whatever you want now
playlist = PrivatePlaylist(instance)
playlist.create_playlist("SpotAPI Showcase!")

# Save the session
instance.save(MongoSaver())

Without User Authentication

"""Here's the example from spotipy https://github.com/spotipy-dev/spotipy?tab=readme-ov-file#quick-start"""
from spotapi import Song

song = Song()
gen = song.paginate_songs("weezer")

# Paginates 100 songs at a time till there's no more
for batch in gen:
    for idx, item in enumerate(batch):
        print(idx, item['item']['data']['name'])
    
# ^ ONLY 6 LINES OF CODE

# Alternatively, you can query a specfic amount
songs = song.query_songs("weezer", limit=20)
data = songs["data"]["searchV2"]["tracksV2"]["items"]
for idx, item in enumerate(data):
    print(idx, item['item']['data']['name'])

With Language Support

from spotapi import Artist, PublicPlaylist, Song

# Initialize with Korean language
artist = Artist(language="ko")
playlist = PublicPlaylist("37i9dQZF1DXcBWIGoYBM5M", language="ko")

# Change language at runtime
song = Song(language="en")
song.base.set_language("ja")  # Switch to Japanese

# Supported languages: ko, ja, zh, en, and any ISO 639-1 code

Results

0 Island In The Sun
1 Say It Ain't So
2 Buddy Holly
.
.
.
18 Holiday
19 We Are All On d***s

Import Cookies

If you prefer not to use a third party CAPTCHA solver, you can import cookies to manage your session.

Steps to Import Cookies:

  1. Choose a Session Saver:

    • Select a session saver for storing your session data.
    • For simplicity, you should use JSONSaver, especially if performance or quantity of sessions is not a big concern.
  2. Prepare Session Data:

    • Create an object with the following keys:
      • identifier: This should be your email address or username.
      • cookies: These are the cookies you obtain when logged in. To get these cookies, visit Spotify, log in, and copy the cookies from your browser.
        • It can be a dict[str, str] or a string representation
  3. Load the Session:

    • Use Login.from_saver (or your own implementation) to load the session from cache. This will enable you to use Spotify with a fully functional session without needing additional CAPTCHA solving.

Contributing

Contributions are welcome! If you find any issues or have suggestions, please open an issue or submit a pull request.

License

This project is licensed under the GPL 3.0 License. See LICENSE for details.

Private Modules

For the full scale account generation and "engagement" modules that can't be posted here, reach out on Telegram: @aran_xyz

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

spotapi-1.2.8.tar.gz (58.5 kB view details)

Uploaded Source

Built Distribution

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

spotapi-1.2.8-py3-none-any.whl (70.3 kB view details)

Uploaded Python 3

File details

Details for the file spotapi-1.2.8.tar.gz.

File metadata

  • Download URL: spotapi-1.2.8.tar.gz
  • Upload date:
  • Size: 58.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for spotapi-1.2.8.tar.gz
Algorithm Hash digest
SHA256 8535c820522e05e6959742e9e636d52a3c151b37130460ff47a46cae283577a1
MD5 55eb5b54dc9ae2c0bbed5fcc1fc48690
BLAKE2b-256 d5b6fe67cb2df5545999ae006f7664de00f55af9ebff65783bf8abd727a0ff90

See more details on using hashes here.

File details

Details for the file spotapi-1.2.8-py3-none-any.whl.

File metadata

  • Download URL: spotapi-1.2.8-py3-none-any.whl
  • Upload date:
  • Size: 70.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for spotapi-1.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 dc5716b215ef207b97249a70347965981c30102899dbe727b1b5f1e643ba179e
MD5 0f69cb93c5aacb60060efde4ef3cc5ed
BLAKE2b-256 3eff0491c208050d5aaab26ede9df11e4e8ff2e1cc0cf0421c8e18deff37c974

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