Question | Answer |
---|---|
What can I do with it? | Retrieve latest data from the Spotify catalog about artists, tracks, and playlists or compute latest music trends. Make real-time recommendations to users, etc.K |
Authorization | Yes, via OAuth 2.0. |
Data format | JSON |
Traffic rate limits | Calls are calculated within 30 seconds, and the number of requests depends on the application base you use. |
API Wrappers | Available for: .NET / C#, Clojure, Elixir, Go, Java / Android, Javascript, Node.JS, Perl, PHP, Python, Ruby. |
Is it free | Yes, you just have to have a Spotify account. |
Commercial license | For commercial use, check the Spotify Developer Policy for permissions and restrictions. |
Privacy policy | You have to respect user privacy and the data specified in the Spotify Developer Agreement. |
Documentation | https://developer.spotify.com/documentation/ |
In this article, we’ll be looking at the Spotify Web API and what it has to offer. Spotify Web API is a service that you can retrieve information from the Spotify catalog about artists, tracks, and playlists. Also, the API provides music search. It was created primarily for developers who want to incorporate Spotify’s music catalog into their app or website.
All requests to the Web API require authentication. This is accomplished by submitting a valid OAuth access token in the request header. The authorization process requires valid client credentials: a client ID and a client secret. Once authorization is granted, the authorization server issues an access token used for API calls on behalf of the user or application.
The OAuth2 standard defines three authorization types for requesting and receiving an access token. Spotify implements the following types:
Authorization Type | Description |
---|---|
Authorization Code + PKCE Extension | Suitable for long-running applications where the user grants permission only once. |
Client Credentials | It’s used in server-to-server authentication and does not involve authorization. |
Implicit granting | This type is executed on the client-side and does not involve secret keys, but the access tokens are short-lived and not renewed by a refresh. |
The Spotify Web API endpoints return JSON metadata about music artists, albums, and tracks directly from the Spotify data catalog based on simple REST principles. The Web API also provides user-related data, which the user stores in their "Music library.” Those include endpoints such as albums, artists, shows, episodes, tracks, search, users, playlists, categories, genres, players, and markets.
Spotify’s Web API limit is calculated based on the number of calls your app makes to Spotify within a 30-second window. There are vague rate limits for the various endpoints. Higher rate limits apply to authorized requests. However, all rate limits apply per app. When talking about Spotify rate limits, you should keep in mind there are two different modes when developing your app based on Spotify Web API:
Method | Action |
---|---|
GET | Retrieves resources |
POST | Creates resources |
PUT | Changes and/or replaces resources |
DELETE | Deletes resources |
Before you get started, you must register for a free or premium account from Spotify to begin using the API. Along with registering, you also need to generate an access token from your account settings. One can be obtained through OAuth 2.0. Once you have the access token and know how to use it, use the API and request data.
Language | Library/Wrapper |
---|---|
.NET / C# | SpotifyAPI-NET |
Clojure | clj-spotify |
Elixir | SpotifyEx |
Go | Spotify Go Wrapper |
Java / Android | Spotify Web API for Android, Spotify Web API Java, Spotify Web API Android |
Javascript | Spotify Web API JS, angular-spotify, meteor-spotify-web-api, Spotify SDK |
Node.JS | Spotify Web API Node |
Perl | WebService-Spotify, WWW-Spotify |
PHP | Spotify Web API PHP, Spotify Web API |
Python | Spotipy, Tekore |
Ruby | spotify-client, RSpotify |
According to the Spotify Developer Policy, developers can access data to create apps on Spotify but must respect user privacy and the data specified in the Developer Agreement.
Spotify’s Web API is available to developers for free. To use the API, you have to create a Spotify user account which can either be Premium or Free.
Using the Spotify Web API is free, but you need to consult the Spotify Developer Policy to create applications for commercial use. There are usage rights and certain restrictions on the use of the APIs that you may not violate, such as the sale of streaming apps, Spotify content or services, any in-app payment or monetization initiated by streaming apps, the sale of advertising, sponsorship, or promotions in the streaming app itself.
The Spotify Web API is a great way to get the latest data on your favorite artist or see the latest music trends. You can also pull data on what albums are most popular right now, what genres are most popular, and even what songs are most popular. If you want to dig deeper into the music itself, you can evaluate the audio characteristics of songs and analyze their various attributes, such as danceability and value. You can also integrate Spotify music into your app, make recommendations to users, and search and manage artists, albums, tracks, or playlists. Here are some examples:
The Spotify API is pretty easy to use, even for inexperienced or junior developers. If you’re starting with your own app development - you should definitely try this API out. You can create a track recommender or something more complex. There are many possibilities. Get inspired by our example from the last year’s hackathon.