Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

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.



Install it using Composer:

composer require jwilsson/spotify-web-api-php


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

Note: Applications created after 2021-05-27 might need to perform some extra steps.

Simple example displaying a user's profile:

require 'vendor/autoload.php';

$session = new SpotifyWebAPI\Session(

$api = new SpotifyWebAPI\SpotifyWebAPI();

if (isset($_GET['code'])) {

} else {
    $options = [
        'scope' => [

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

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.


Contributions are more than welcome! See for more info.


MIT license. Please see for more info.