pouler / spotify-artists-api
PHP Package for the (unofficial) Spotify Artists API
Installs: 3 021
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 0
Open Issues: 1
Requires
- php: >=8.1
- ext-json: *
- pouler/spotify-login: ^0.3
- symfony/http-client: ^5.4|^6
- symfony/property-access: ^5.4|^6
- symfony/serializer: ^5.4|^6
Requires (Dev)
- phpunit/phpunit: ^9
- squizlabs/php_codesniffer: ^3.0
Suggests
- pouler/spotify-login: To obtain an access token to be used in API calls
README
This is a PHP wrapper for the (unofficial) Spotify Artists API.
Requirements
- PHP >=8.1
Installation
Install it using Composer:
composer require pouler/spotify-artists-api
Spotify login
You can obtain an access token by using the SpotifyLogin class, this dependency can be installed by using:
composer require pouler/spotify-login
For more information about this project see: https://github.com/PouleR/spotify-login
Example usage
<?php declare(strict_types=1); require 'vendor/autoload.php'; $httpClient = new \Symfony\Component\HttpClient\CurlHttpClient(); $apiClient = new \PouleR\SpotifyArtistsAPI\SpotifyArtistsAPIClient($httpClient); $artistsApi = new \PouleR\SpotifyArtistsAPI\SpotifyArtistsAPI($apiClient); $loginClient = new \PouleR\SpotifyLogin\SpotifyLoginClient($httpClient); $spotifyLogin = new \PouleR\SpotifyLogin\SpotifyLogin($loginClient); $spotifyLogin->setClientId('clientId'); $spotifyLogin->setDeviceId('deviceId'); // Log in and get the access token $accessToken = $spotifyLogin->login('email@address.com','password'); // Use this token for the artists API $artistsApi->setAccessToken($accessToken); $upcoming = $artistsApi->getUpcomingReleases('artistId'); print_r($upcoming); $realtime = $artistsApi->getRealTimeStatistics('artistId', 'trackId'); print_r($realtime);