Download the PHP package ngiraud/spotify-sdk-php without Composer
On this page you can find all versions of the php package ngiraud/spotify-sdk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package spotify-sdk-php
SDK for using Spotify in PHP
This package contains the PHP SDK to work with the Spotify Web API.
Table of Contents
- Get Started
- Usage
- Handling Pagination
- Albums Resource
- Artists Resource
- Audiobooks Resource
- Categories Resource
- Chapters Resource
- Episodes Resource
- Genres Resource
- Markets Resource
- Player Resource
- Playlists Resource
- Search Resource
- Shows Resource
- Tracks Resource
- Users Resource
- Testing
- Linting
- Changelog
- Contributing
- Security Vulnerabilities
- Credits
- License
Get Started
Requires PHP 8.1+
First, install the client via the Composer package manager:
You must also install Guzzle if your project does not already have a it integrated:
In order to use the SDK, you need to request an access_token. You can get an example from the Spotify Web API docs.
If you use Laravel, you can use Socialite and the adapter provided by the community on their website.
Below is an example on how to authenticate with Laravel Socialite.
You can now interact with Spotify's API:
You can also use the Client Credentials flow to authenticate:
Please keep in mind that only endpoints that do not access user information can be accessed using this particular authentication flow.
Usage
Handling Pagination
On some resources, some methods such as findMultiple
will return an instance of Spotify\Support\PaginatedResults
.
This instance returns a list of records, and can handle other things like fetch the next or previous page of results.
Available methods
results()
links()
previousUrl()
nextUrl()
previous()
next()
meta()
total()
Albums
Resource
You can access the Albums resource via the albums
method from the client.
Available methods:
find()
findMultiple()
tracks()
findSaved()
save()
deleteSaved()
checkSaved()
newReleases()
Example
Artists
Resource
You can access the Artists resource via the artists
method from the client.
Available methods:
find()
findMultiple()
albums()
topTracks()
relatedArtists()
Example
Audiobooks
Resource
Note: Audiobooks are only available for the US, UK, Ireland, New Zealand and Australia markets.
You can access the Audiobooks resource via the audiobooks
method from the client.
Available methods:
find()
findMultiple()
chapters()
findSaved()
save()
deleteSaved()
checkSaved()
Example
Categories
Resource
You can access the Categories resource via the categories
method from the client.
Available methods:
find()
browse()
Example
Chapters
Resource
You can access the Chapters resource via the chapters
method from the client.
Available methods:
find()
findMultiple()
Example
Episodes
Resource
You can access the Episodes resource via the episodes
method from the client.
Available methods:
find()
findMultiple()
findSaved()
save()
deleteSaved()
checkSaved()
Example
Genres
Resource
You can access the Genres resource via the genres
method from the client.
Available methods:
seeds()
Example
Markets
Resource
You can access the Markets resource via the markets
method from the client.
Available methods:
all()
Example
Player
Resource
You can access the Player resource via the player
method from the client.
Available methods:
state()
transfer()
availableDevices()
currentlyPlayingTrack()
start()
pause()
next()
previous()
seek()
repeat()
volume()
shuffle()
recentlyPlayedTracks()
queue()
addToQueue()
Example
Playlists
Resource
You can access the Playlists resource via the playlists
method from the client.
Available methods:
find()
forCurrentUser()
forUser()
create()
update()
tracks()
reorderTracks()
replaceTracks()
addTracks()
deleteTracks()
featured()
forCategory()
coverImage()
addCoverImage()
Example
Search
Resource
You can access the Search resource via the search
method from the client.
The search method will return an instance of Spotify\SingleObjects\Search
, and every type of results is accessible via its own method.
This end method will return an instance of Spotify\Support\PaginatedResults
.
Available methods after the search
audiobooks()
albums()
artists()
episodes()
playlists()
shows()
tracks()
Example
Shows
Resource
You can access the Shows resource via the shows
method from the client.
Available methods:
find()
findMultiple()
episodes()
findSaved()
save()
deleteSaved()
checkSaved()
Example
Tracks
Resource
You can access the Tracks resource via the tracks
method from the client.
Available methods:
find()
findMultiple()
findSaved()
save()
deleteSaved()
checkSaved()
audioFeatures()
audioAnalysis()
recommendations()
Example
Users
Resource
You can access the Users resource via the users
method from the client.
Available methods:
me()
profile()
topArtists()
topTracks()
topItems()
followPlaylist()
unfollowPlaylist()
followingPlaylist()
followedArtists()
followArtists()
followUsers()
followArtistsOrUsers()
unfollowArtists()
unfollowUsers()
unfollowArtistsOrUsers()
followingArtists()
followingUsers()
followingArtistsOrUsers()
Example
Testing
Linting
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
This package is inspired by the OpenAI PHP client package made by Nuno Maduro and Sandro Gehri and the Mailcoach API SDK from Spatie.
- Nicolas Giraud
- All Contributors
License
The MIT License (MIT). Please see License File for more information.