You can use Spotify's Web API to discover music and podcasts, manage your Spotify library, control audio playback, and much more. Browse our available Web API endpoints using the sidebar at left, or via the navigation bar on top of this page on smaller screens.
In order to make successful Web API requests your app will need a valid access token. One can be obtained through OAuth 2.0.
The base URI for all Web API requests is https://api.spotify.com/v1.
Need help? See our Web API guides for more information, or visit the Spotify for Developers community forum to ask questions and connect with other developers.
Install the SDK by adding the following dependency in your project's pom.xml file:
<dependency>
<groupId>io.sdks</groupId>
<artifactId>spotify-api-sdk</artifactId>
<version>1.0.0</version>
</dependency>You can also view the package at: https://central.sonatype.com/artifact/io.sdks/spotify-api-sdk/1.0.0
Note: Documentation for the client can be found here.
The following parameters are configurable for the API Client:
| Parameter | Type | Description |
|---|---|---|
environment |
Environment |
The API environment. Default: Environment.PRODUCTION |
httpClientConfig |
Consumer<HttpClientConfiguration.Builder> |
Set up Http Client Configuration instance. |
authorizationCodeAuth |
AuthorizationCodeAuth |
The Credentials Setter for OAuth 2 Authorization Code Grant |
The API client can be initialized as follows:
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.httpClientConfig(configBuilder -> configBuilder
.timeout(0))
.authorizationCodeAuth(new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.oAuthScopes(Arrays.asList(
OAuthScopeEnum.APP_REMOTE_CONTROL,
OAuthScopeEnum.PLAYLIST_READ_PRIVATE
))
.build())
.environment(Environment.PRODUCTION)
.build();API calls return an ApiResponse object that includes the following fields:
| Field | Description |
|---|---|
getStatusCode |
Status code of the HTTP response |
getHeaders |
Headers of the HTTP response as a Hash |
getResult |
The deserialized body of the HTTP response as a String |
This API uses the following authentication schemes.