spotify-web-api-java
A Java wrapper for Spotify's Web API using Retrofit
I am currently working on a new spotify-web-api-java
library that is generated automatically from the Spotify Web Api documentation. Check out the new project here.
Example: Get the number of tracks of a playlist
AuthenticationProvider authProvider = ...;
SpotifyApi api = new AuthenticatedSpotifyApi(authProvider);
try {
Playlist playlist = api.callApiAndReturnBody(
api.getPlaylistsService().getPlaylist("spotify:playlist:37i9dQZEVXbMDoHDwVN2tF"));
System.out.printf("Playlist %s has %s tracks\n", playlist.name, playlist.tracks.total);
}
catch (SpotifyApiException e) {
System.err.println(e.getMessage());
}
Authentication and Authorization
All calls to the Spotify Web Api need authorization. Therefore, it is mandatory to provide the required authentication
and authorization data. Spotify provides multiple authorization flows.
This library provides two option for authentication and authorization:
- The
AuthenticatedSpotifyApi
provides support for the authorization code flow. Therefore, only the
AuthenticationProvider
interface must be implemented. - The
SpotifyWebApi
provides no built in authentication or authorization, but a OkHttpClient
can be provided
to customize the authentication and authorization. For example a custom Interceptor
can be used to add the access token to every request.
Releases
spotify-web-api-java
is available on Maven Central:
Maven
<dependency>
<groupId>de.jsone-studios</groupId>
<artifactId>spotify-web-api-java</artifactId>
<version>1.3.3</version>
</dependency>
Gradle
dependencies {
compile 'de.jsone-studios:spotify-web-api-java:1.3.3'
}
Why does the groupId
not match my username?
I have changed my GitHub username from jsone-studios
to sonallux
after releasing this library on maven central.
Because a groupId
cannot be changed on maven central, I am going to stick with the old name for this library.
Deploy a new release to Maven Central
- Update version number
- Commit changes
- Create signed git tag with
git tag -s <tag>
- Run
mvn clean deploy -Pdeploy
- Update version number to next SNAPSHOT version