{"id":16458234,"url":"https://github.com/kirilkirkov/spotify-webapi-php-sdk","last_synced_at":"2025-06-14T21:39:08.579Z","repository":{"id":57006881,"uuid":"231798662","full_name":"kirilkirkov/Spotify-WebApi-PHP-SDK","owner":"kirilkirkov","description":"Easy to use sdk with all the functionality of the Spotify Web Api through Guzzle with support of automated updates of access token and integrated pagination for results.","archived":false,"fork":false,"pushed_at":"2024-03-03T07:34:01.000Z","size":140,"stargazers_count":16,"open_issues_count":0,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-20T06:36:34.165Z","etag":null,"topics":["guzzle","php-sdk","sdk","spotify","spotify-api","spotify-api-wrapper","spotify-connect","spotify-library","spotify-php","spotify-plugin","spotify-sdk","spotify-web-api","spotify-web-api-laravel","spotify-web-api-php","spotify-web-sdk"],"latest_commit_sha":null,"homepage":"https://developer.spotify.com/documentation/web-api/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kirilkirkov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"kirilkirkov"}},"created_at":"2020-01-04T17:03:28.000Z","updated_at":"2024-11-06T14:45:23.000Z","dependencies_parsed_at":"2024-03-03T08:28:13.802Z","dependency_job_id":"77b40630-7f88-42f8-8bcb-4a4d3b5b553c","html_url":"https://github.com/kirilkirkov/Spotify-WebApi-PHP-SDK","commit_stats":{"total_commits":55,"total_committers":2,"mean_commits":27.5,"dds":"0.19999999999999996","last_synced_commit":"4acc4814dcf722ac2c6ab84b72170f3a334bed7b"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/kirilkirkov/Spotify-WebApi-PHP-SDK","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirilkirkov%2FSpotify-WebApi-PHP-SDK","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirilkirkov%2FSpotify-WebApi-PHP-SDK/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirilkirkov%2FSpotify-WebApi-PHP-SDK/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirilkirkov%2FSpotify-WebApi-PHP-SDK/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kirilkirkov","download_url":"https://codeload.github.com/kirilkirkov/Spotify-WebApi-PHP-SDK/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirilkirkov%2FSpotify-WebApi-PHP-SDK/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259888188,"owners_count":22927072,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["guzzle","php-sdk","sdk","spotify","spotify-api","spotify-api-wrapper","spotify-connect","spotify-library","spotify-php","spotify-plugin","spotify-sdk","spotify-web-api","spotify-web-api-laravel","spotify-web-api-php","spotify-web-sdk"],"created_at":"2024-10-11T10:44:40.510Z","updated_at":"2025-06-14T21:39:08.547Z","avatar_url":"https://github.com/kirilkirkov.png","language":"PHP","funding_links":["https://github.com/sponsors/kirilkirkov","https://www.paypal.com/donate/?hosted_button_id=7U9TVUV3URTK6"],"categories":[],"sub_categories":[],"readme":"# PHP SDK For Spotify Web Api\n\n\u003cimg src=\"https://raw.githubusercontent.com/kirilkirkov/Spotify-WebApi-PHP-SDK/master/.github/logo%402x.png\" alt=\"Spotify PHP\" width=\"380px\" /\u003e\n\n\u003cp\u003erequires php \u003e= 7.2\u003c/p\u003e\n\n- Integrated Pagination\n- Automated Token Refresh\n- Separate Services Files For All Api References\n- Guzzle Requests\n\n## Installation\ncomposer require kirilkirkov/spotify-webapi-sdk\n\n\u003cp\u003eExample usage with code:\u003c/p\u003e\nhttps://github.com/kirilkirkov/Spotify-WebApi-PHP-SDK/wiki/Example-Usage-with-Code\n\n## Doesnt have token?\n\n### Option 1 - Get access token with client credentials\n\n```\nuse SpotifyWebAPI\\SpotifyWebApi;\n\ntry {\n    $spotifyWebApi = new SpotifyWebApi();\n    $token_obj = $spotifyWebApi-\u003egetAccessTokenWithCredentials(\n        'CLIENT_ID',\n        'CLIENT_SECRET'\n    );\n    echo $token_obj-\u003eaccess_token;\n    // echo $token_obj-\u003etoken_type;\n    // echo $token_obj-\u003eexpires_in;\n} catch(\\SpotifyWebAPI\\SpotifyWebAPIException $e) {\n    echo $e-\u003egetMessage();\n}\n```\n\n### Option 2 - Get access token with code authorization (recommended)\nBefore make requests you must add yours Redirect URIs to https://developer.spotify.com/dashboard\n\nGet redirect url for code:\n```\nuse SpotifyWebAPI\\SpotifyWebApi;\n\ntry {\n    $spotifyWebApi = new SpotifyWebApi([\n        'clientId' =\u003e 'CLIENT_ID',\n        'clientSecret' =\u003e 'CLIENT_SECRET',\n    ]);\n\n    $callBackUrl = 'http://yoursite.com/callback';\n    $url = $spotifyWebApi-\u003egetUrlForCodeToken($callBackUrl);\n    header(\"Location: {$url}\");\n} catch(\\SpotifyWebAPI\\SpotifyWebAPIException $e) {\n    echo $e-\u003egetMessage();\n}\n```\n\nAfter signup in spotify you will be redirected back to provided above callback url (http://yoursite.com/callback) with parameter **$_GET['code']** with the code that can get token with following command:\n```\nuse SpotifyWebAPI\\SpotifyWebApi;\n\ntry {\n    $spotifyWebApi = new SpotifyWebApi();\n    $tokens = $spotifyWebApi-\u003egetAccessTokenWithCode(\n        'YOUR_CODE',\n        'http://yoursite.com/callback'\n    );\n} catch(\\SpotifyWebAPI\\SpotifyWebAPIException $e) {\n    echo $e-\u003egetMessage();\n}\n```\n\nAnd you will receive array with *accessToken* and *refreshToken* in the example above **$tokens**.\n\n### Access/Refresh Tokens\nSpotify 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).\n\nIf you set $spotifyWebApi-\u003ereturnNewTokenIfIsExpired(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. \nYou can also generate access token with refresh token manually with\n```\nuse SpotifyWebAPI\\SpotifyWebApi;\n\ntry {\n    $spotifyWebApi = new SpotifyWebApi([\n        'clientId' =\u003e 'CLIENT_ID',\n        'clientSecret' =\u003e 'CLIENT_SECRET',\n        'accessToken' =\u003e $oldAccessToken,\n        'refreshToken' =\u003e 'REFRESH_TOKEN',\n    ]);\n    $result = $spotifyWebApi-\u003erefreshAccessToken();\n} catch(\\SpotifyWebAPI\\SpotifyWebAPIException $e) {\n    echo $e-\u003egetMessage();\n}\n```\n\nand save final expire timestamp with  time() + $result-\u003eexpires_in. You can manualy generate new access token every time when saved in your database expired time is end.\n\n### Suggestions\n\nIt 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.\n\nCan increase your execution time of scripts \nini_set('max_execution_time', XXX); and set_time_limit(XXX);\n\n### Functions\nIn the wiki of this repository you can find all functions available in this sdk (all the ones supported by Spotify have been integrated so far)\n- https://github.com/kirilkirkov/Spotify-WebApi-PHP-SDK/wiki/Functions-and-examples\n- https://github.com/kirilkirkov/Spotify-WebApi-PHP-SDK/wiki/Pagination Integrated Pagination Example\n\n## Donate\n\u003cp\u003eIf this project help you reduce time to develop, you can give me a cup of coffee to continue its development. Thank you! :)\u003c/p\u003e\n\n[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/donate/?hosted_button_id=7U9TVUV3URTK6)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkirilkirkov%2Fspotify-webapi-php-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkirilkirkov%2Fspotify-webapi-php-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkirilkirkov%2Fspotify-webapi-php-sdk/lists"}