A PHP wrapper for Spotify's Web API.
Find a file
Jonathan Wilsson ae0886d885 7.1.0 changelog
2026-02-19 19:47:14 +01:00
.github/workflows Switch to PER 3.x coding standard 2025-12-14 11:12:43 +01:00
docs Update docs 2026-02-19 19:30:00 +01:00
src Add SpotifyWebAPI::updatePlaylistItems() method 2026-02-19 19:30:00 +01:00
tests Add SpotifyWebAPI::updatePlaylistItems() method 2026-02-19 19:30:00 +01:00
.gitignore Switch to PER 3.x coding standard 2025-12-14 11:12:43 +01:00
.php-cs-fixer.dist.php Switch to PER 3.x coding standard 2025-12-14 11:12:43 +01:00
CHANGELOG.md 7.1.0 changelog 2026-02-19 19:47:14 +01:00
composer.json Switch to PER 3.x coding standard 2025-12-14 11:12:43 +01:00
CONTRIBUTING.md Switch to PER 3.x coding standard 2025-12-14 11:12:43 +01:00
LICENSE.md Add License 2014-06-17 22:01:03 +02:00
phpunit.dist.xml Update to PHPUnit 10 2023-07-31 12:22:05 +02:00
phpunit.php Fix faulty proxy header detection regex 2025-12-14 11:12:43 +01:00
README.md Update docs 2026-02-19 19:30:00 +01:00

Spotify Web API PHP

Packagist build Coverage Status

This is a PHP wrapper for Spotify's Web API. It includes the following:

  • Helper methods for all API endpoints:
    • Information about artists, albums, tracks, podcasts, audiobooks, and users.
    • List music featured by Spotify.
    • Playlist and user music library management.
    • Spotify catalog search.
    • User playback control.
  • Authorization flow helpers.
  • Automatic refreshing of access tokens.
  • Automatic retry of rate limited requests.
  • PSR-4 autoloading support.

Requirements

Installation

Install it using Composer:

composer require jwilsson/spotify-web-api-php

Usage

Before using the Spotify Web API, you'll need to create an app at Spotifys developer site.

Simple example displaying a user's profile:

require 'vendor/autoload.php';

$session = new SpotifyWebAPI\Session(
    'CLIENT_ID',
    'CLIENT_SECRET',
    'REDIRECT_URI'
);

$api = new SpotifyWebAPI\SpotifyWebAPI();

if (isset($_GET['code'])) {
    $session->requestAccessToken($_GET['code']);
    $api->setAccessToken($session->getAccessToken());

    print_r($api->me());
} else {
    $options = [
        'scope' => [
            'user-read-email',
        ],
    ];

    header('Location: ' . $session->getAuthorizeUrl($options));
    die();
}

For more instructions and examples, check out the documentation.

The Spotify Web API Console can also be of great help when trying out the API.

Contributing

Contributions are more than welcome! See CONTRIBUTING.md for more info.

License

MIT license. Please see LICENSE.md for more info.