PHPackages                             arunchaitanyajami/spotify-webapi-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. arunchaitanyajami/spotify-webapi-sdk

ActiveLibrary[API Development](/categories/api)

arunchaitanyajami/spotify-webapi-sdk
====================================

Spotify WebApi PHP Library

1.0.1(9mo ago)01MITPHPPHP &gt;=7.2.0

Since Jul 18Pushed 9mo agoCompare

[ Source](https://github.com/arunchaitanyajami/spotify-web-api-sdk)[ Packagist](https://packagist.org/packages/arunchaitanyajami/spotify-webapi-sdk)[ RSS](/packages/arunchaitanyajami-spotify-webapi-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

PHP SDK For Spotify Web Api
===========================

[](#php-sdk-for-spotify-web-api)

requires php &gt;= 7.2

- Integrated Pagination
- Automated Token Refresh
- Separate Services Files For All Api References
- Guzzle Requests

Installation
------------

[](#installation)

composer require arunchaitanyajami/spotify-webapi-sdk

Doesnt have token?
------------------

[](#doesnt-have-token)

### Option 1 - Get access token with client credentials

[](#option-1---get-access-token-with-client-credentials)

```
use SpotifyWebApiSdk\SpotifyWebApiSdk;

try {
    $spotifyWebApi = new SpotifyWebApiSdk();
    $token_obj = $spotifyWebApi->getAccessTokenWithCredentials(
        'CLIENT_ID',
        'CLIENT_SECRET'
    );
    echo $token_obj->access_token;
    // echo $token_obj->token_type;
    // echo $token_obj->expires_in;
} catch(\SpotifyWebAPI\SpotifyWebAPIException $e) {
    echo $e->getMessage();
}

```

### Option 2 - Get access token with code authorization (recommended)

[](#option-2---get-access-token-with-code-authorization-recommended)

Before make requests you must add yours Redirect URIs to

Get redirect url for code:

```
use SpotifyWebApiSdk\SpotifyWebApiSdk;

try {
    $spotifyWebApi = new SpotifyWebApiSdk([
        'clientId' => 'CLIENT_ID',
        'clientSecret' => 'CLIENT_SECRET',
    ]);

    $callBackUrl = 'http://yoursite.com/callback';
    $url = $spotifyWebApi->getUrlForCodeToken($callBackUrl);
    header("Location: {$url}");
} catch(\SpotifyWebAPI\SpotifyWebAPIException $e) {
    echo $e->getMessage();
}

```

After signup in spotify you will be redirected back to provided above callback url () with parameter **$\_GET\['code'\]** with the code that can get token with following command:

```
use SpotifyWebApiSdk\SpotifyWebApiSdk;

try {
    $spotifyWebApi = new SpotifyWebApiSdk();
    $tokens = $spotifyWebApi->getAccessTokenWithCode(
        'YOUR_CODE',
        'http://yoursite.com/callback'
    );
} catch(\SpotifyWebAPI\SpotifyWebAPIException $e) {
    echo $e->getMessage();
}

```

And you will receive array with *accessToken* and *refreshToken* in the example above **$tokens**.

### Access/Refresh Tokens

[](#accessrefresh-tokens)

Spotify tokens are valid 1 hour. If your token is expired and you make a call, the sdk auto renew access token with provided refresh token in every query (as there is no safe place to automatically save it).

If you set $spotifyWebApi-&gt;returnNewTokenIfIsExpired(true); before your request calls, if access token is expired will be returned from the query, object with the new access\_token, then you can save it in database and recall request with a fresh Access token. You can also generate access token with refresh token manually with

```
use SpotifyWebApiSdk\SpotifyWebApiSdk;

try {
    $spotifyWebApi = new SpotifyWebApiSdk([
        'clientId' => 'CLIENT_ID',
        'clientSecret' => 'CLIENT_SECRET',
        'accessToken' => $oldAccessToken,
        'refreshToken' => 'REFRESH_TOKEN',
    ]);
    $result = $spotifyWebApi->refreshAccessToken();
} catch(\SpotifyWebAPI\SpotifyWebAPIException $e) {
    echo $e->getMessage();
}

```

and save final expire timestamp with time() + $result-&gt;expires\_in. You can manualy generate new access token every time when saved in your database expired time is end.

### Suggestions

[](#suggestions)

It is good practise to add ip of the api that you call in the hosts file in yours server os because Guzzle sometime cannot resolve the dns.

Can increase your execution time of scripts ini\_set('max\_execution\_time', XXX); and set\_time\_limit(XXX);

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance59

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

294d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2f70ccdeff28cb90ca487099b18a228a95da5b94adb7cac94930356c401af922?d=identicon)[arunchaitanyajami](/maintainers/arunchaitanyajami)

---

Top Contributors

[![iamarunchaitanyajami](https://avatars.githubusercontent.com/u/110028555?v=4)](https://github.com/iamarunchaitanyajami "iamarunchaitanyajami (3 commits)")

---

Tags

spotifyspotify-apispotify-web-apispotify-php-sdk

### Embed Badge

![Health badge](/badges/arunchaitanyajami-spotify-webapi-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/arunchaitanyajami-spotify-webapi-sdk/health.svg)](https://phpackages.com/packages/arunchaitanyajami-spotify-webapi-sdk)
```

###  Alternatives

[aerni/laravel-spotify

A Laravel wrapper for the Spotify Web API

209145.6k](/packages/aerni-laravel-spotify)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[jwilsson/spotify-web-api-php

A PHP wrapper for Spotify's Web API.

8841.3M8](/packages/jwilsson-spotify-web-api-php)[mmoreram/spotify-api-bundle

Easy Spotify Api interface for Symfony2 projects

148.5k](/packages/mmoreram-spotify-api-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
