rem42 / scraper-spotify
Spotify API Scraper
dev-main
2026-10-26 20:01 UTC
Requires
- php: ^8.4
- ext-json: *
- rem42/scraper: ^3.4
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^13.1
- rem42/php-cs-fixer-config: ^4.1
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-26 20:01:17 UTC
README
Scraper can handle multiple request type and transform them into object in order to create some API.
Installation
composer require rem42/scraper-spotify
Requirement
- PHP >= 8.4
Usage
The Spotify Web API needs an access token. Get one with the client credentials of your app
(https://developer.spotify.com/dashboard); it is valid for expiresIn seconds (1 hour).
use Scraper\Scraper\Client; use Scraper\ScraperSpotify\Request\SpotifyAlbumRequest; use Scraper\ScraperSpotify\Request\SpotifySearchAlbumRequest; use Scraper\ScraperSpotify\Request\SpotifyTokenRequest; use Symfony\Component\HttpClient\HttpClient; $client = new Client(HttpClient::create()); /** @var \Scraper\ScraperSpotify\Model\Token $token */ $token = $client->send(new SpotifyTokenRequest('clientId', 'clientSecret')); /** @var \Scraper\ScraperSpotify\Model\SearchAlbum $search */ $search = $client->send( (new SpotifySearchAlbumRequest($token->accessToken)) ->setQuery('eminem') ->setMarket('FR') ->setLimit(10) ); foreach ($search->albums->items as $album) { echo $album->id, ' ', $album->name, ' (', $album->releaseDate?->format('Y'), ')', PHP_EOL; } /** @var \Scraper\ScraperSpotify\Model\Album $album */ $album = $client->send( (new SpotifyAlbumRequest($token->accessToken)) ->setId('2cWBwpqMsDJC1ZUwz813lo') ->setMarket('FR') );
Notes:
- Without
market(and with a client credentials token), Spotify considers the content unavailable. - Search
limitis between 0 and 10 (default 5),offsetbetween 0 and 1000. - Since February 2026, development mode apps no longer get
label,popularityandavailable_marketson albums: these properties staynull/ empty.