# Spotify Web API
> 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.
Authentication
- **OAuth 2 Authorization Code Grant**:
- OAuthClientId: OAuth 2 Client ID
- OAuthClientSecret: OAuth 2 Client Secret
- OAuthRedirectUri: OAuth 2 Redirection endpoint or Callback Uri
- OAuthToken: Object for storing information about the OAuth token
- OAuthScopes: List of scopes that apply to the OAuth token
# Overview
Retrieve metadata from Spotify content, control playback or get recommendations
Spotify Web API enables the creation of applications that can interact with Spotify's streaming service, such as retrieving content metadata, getting recommendations, creating and managing playlists, or controlling playback.
## Getting Started
This is where the magic begins! The following steps will help you to get started with your journey towards creating some awesome music apps using the API:
- Log into the [dashboard](https://developer.spotify.com/dashboard) using your Spotify account.
- [Create an app](page:concepts/apps) and select "Web API" for the question asking which APIs are you planning to use. Once you have created your app, you will have access to the app credentials. These will be required for API [authorization](page:concepts/authorization) to obtain an [access token](page:concepts/access-token).
- Use the [access token](page:concepts/access-token) in your [API requests](page:concepts/api-calls).
- You can follow the [Getting started](page:overview/getting-started) tutorial to learn how to make your first Web API call.
## Documentation
The documentation is organized as follows:
- Concepts that clarify key topics
- Tutorials, which serve as an introduction to important topics when using Web API
- How-Tos, step-by-step guides that cover practical tasks or use cases
- Reference, the API specification
## API Reference
The Spotify Web API provides a wide range of functionality for developers, including:
- Retrieve data from your favourite artist, album or show.
- Search for Spotify content.
- Control and interact with the playback, play and resume, Seek to a position or retrieve your queue.
- Manage your personal library, by creating a new playlist and adding your favourite tracks to it.
- Get recommendations based on the music you listen the most.
And much more! You can find a complete list of available endpoints in the [API Reference]($e/Albums/get-an-album).
## Support
If you have any questions or run into any issues while using the Spotify Web API, you can find help in the [Spotify Developer Community](https://community.spotify.com/t5/Spotify-for-Developers/bd-p/Spotify_Developer). Here, you can connect and get help from other developers.
## Legal
By using Spotify Web API, you accept the [Spotify Developer Terms of Service](https://developer.spotify.com/terms).
# Getting Started with the Web API
This tutorial will help you to make your first Web API call by retriving an artist's metadata. The steps to do so are the following:
1. Create an app, if you haven't done so.
2. Request an access token.
3. Use the access token to request the artist data.
4. Here we go, let's rock & roll!
## Prerequisites
- This tutorial assumes you have a Spotify account (free or premium).
- We will use cURL to make API calls. You can install it from [here](https://curl.se/download.html) our using the package manager of your choice.
## Set Up Your Account
Login to the [Spotify Developer Dashboard](https://developer.spotify.com/dashboard). If necessary, read the latest [Developer Terms of Service](https://developer.spotify.com/terms) to complete your account set up.
## Create an app
An app provides the Client ID and Client Secret needed to request an access token by implementing any of the [authorization](page:concepts/authorization) flows.
To create an app, go to [your Dashboard](https://developer.spotify.com/dashboard), click on the Create an app button and enter the following information:
- App Name: My App
- App Description: This is my first Spotify app
- Redirect URI: You won't need this parameter in this example, so let's use http://localhost:3000.
Finally, check the Developer Terms of Service checkbox and tap on the Create button.
## Request an access token
The access token is a string which contains the credentials and permissions that can be used to access a given resource (e.g artists, albums or tracks) or user's data (e.g your profile or your playlists).
In order to request the access token you need to get your Client_ID and Client Secret:
1. Go to the [Dashboard](https://developer.spotify.com/dashboard)
2. Click on the name of the app you have just created (My App)
3. Click on the Settings button
The Client ID can be found here. The Client Secret can be found behind the View client secret link.
With our credentials in hand, we are ready to request an access token. This tutorial uses the Client Credentials, so we must:
- Send a POST request to the token endpoint URI.
- Add the Content-Type header set to the application/x-www-form-urlencoded value.
- Add a HTTP body containing the Client ID and Client Secret, along with the grant_type parameter set to client_credentials.
```bash
curl -X POST "https://accounts.spotify.com/api/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=your-client-id&client_secret=your-client-secret"
```
The response will return an access token valid for 1 hour:
```bash
{
"access_token": "BQDBKJ5eo5jxbtpWjVOj7ryS84khybFpP_lTqzV7uV-T_m0cTfwvdn5BnBSKPxKgEb11",
"token_type": "Bearer",
"expires_in": 3600
}
```
## Request artist data
For this example, we will use the Get Artist endpoint to request information about an artist. According to the API Reference, the endpoint needs the Spotify ID of the artist.
An easy way to get the Spotify ID of an artist is using the Spotify Desktop App:
1. Search the artist
2. Click on the three dots icon from the artist profile
3. Select Share > Copy link to artist. The Spotify ID is the value that comes right after the open.spotify.com/artist URI.
Our API call must include the access token we have just generated using the Authorization header as follows:
```bash
curl "https://api.spotify.com/v1/artists/4Z8W4fKeB5YxbusRsdQVPb" \
-H "Authorization: Bearer BQDBKJ5eo5jxbtpWjVOj7ryS84khybFpP_lTqzV7uV-T_m0cTfwvdn5BnBSKPxKgEb11"
```
If everything goes well, the API will return the following JSON response:
```bash
{
"external_urls": {
"spotify": "https://open.spotify.com/artist/4Z8W4fKeB5YxbusRsdQVPb"
},
"followers": {
"href": null,
"total": 7625607
},
"genres": [
"alternative rock",
"art rock",
"melancholia",
"oxford indie",
"permanent wave",
"rock"
],
"href": "https://api.spotify.com/v1/artists/4Z8W4fKeB5YxbusRsdQVPb",
"id": "4Z8W4fKeB5YxbusRsdQVPb",
"images": [
{
"height": 640,
"url": "https://i.scdn.co/image/ab6761610000e5eba03696716c9ee605006047fd",
"width": 640
},
{
"height": 320,
"url": "https://i.scdn.co/image/ab67616100005174a03696716c9ee605006047fd",
"width": 320
},
{
"height": 160,
"url": "https://i.scdn.co/image/ab6761610000f178a03696716c9ee605006047fd",
"width": 160
}
],
"name": "Radiohead",
"popularity": 79,
"type": "artist",
"uri": "spotify:artist:4Z8W4fKeB5YxbusRsdQVPb"
}
```
Congratulations! You made your first API call to the Spotify Web API.
## Summary
The Spotify Web API provides different endpoints depending on the data we want to access. The API calls must include the Authorization header along with a valid access token.
This tutorial makes use of the client credentials grant type to retrieve the access token. That works fine in scenarios where you control the API call to Spotify, for example where your backend is connecting to the Web API. It will not work in cases where your app will connect on behalf of a specific user, for example when getting private playlist or profile data.
## What's next?
- The tutorial used the Spotify Desktop App to retrieve the Spotify ID of the artist. The ID can also be retrieved using the Search endpoint. An interesting exercise would be to extend the example with a new API call to the /search endpoint. Do you accept the challenge?
- The authorization guide provides detailed information about which authorization flow suits you best. Make sure you read it first!
- You can continue your journey by reading the API calls guide which describes in detail the Web API request and responses.
- Finally, if you are looking for a more practical documentation, you can follow the Display your Spotify Profile Data in a Web App how-to which implements a step-by-step web application using authorization code flow to request the access token.
# Access Token
The access token is a string which contains the credentials and permissions that can be used to access a given resource (e.g artists, albums or tracks) or user's data (e.g your profile or your playlists).
To use the access token you must include the following header in your API calls:
| Header Parameter | Value |
|---|---|
| Authorization | Valid access token following the format: Bearer |
Note that the access token is valid for 1 hour (3600 seconds). After that time, the token expires and you need to request a new one.
## Examples
The following example uses cURL to retrieve information about a track using the Get a track endpoint:
```bash
curl --request GET \
'https://api.spotify.com/v1/tracks/2TpxZ7JUBn3uw46aR7qd6V' \
--header "Authorization: Bearer NgCXRK...MzYjw"
```
The following code implements the getProfile() function which performs the API call to the Get Current User's Profile endpoint to retrieve the user profile related information:
```javascript
async function getProfile(accessToken) {
let accessToken = localStorage.getItem('access_token');
const response = await fetch('https://api.spotify.com/v1/me', {
headers: {
Authorization: 'Bearer ' + accessToken
}
});
const data = await response.json();
}
```
# API calls
The Spotify Web API is a restful API with different endpoints which return JSON metadata about music artists, albums, and tracks, directly from the Spotify Data Catalogue.
## Base URL
The base address of Web API is `https://api.spotify.com`.
## Authorization
All requests to Spotify Web API require authorization. Make sure you have read the [authorization](page:concepts/authorization) guide to understand the basics.
To access private data through the Web API, such as user profiles and playlists, an application must get the user’s permission to access the data.
## Requests
Data resources are accessed via standard HTTP requests in UTF-8 format to an API endpoint. The Web API uses the following HTTP verbs:
| Method | Action |
| ------ | ------------------------------------------------ |
| GET | Retrieves resources |
| POST | Creates resources |
| PUT | Changes and/or replaces resources or collections |
| DELETE | Deletes resources |
## Responses
Web API normally returns JSON in the response body. Some endpoints (e.g [Change Playlist Details]($e/Playlists/change-playlist-details)) don't return JSON but the HTTP status code
### Response Status Codes
Web API uses the following response status codes, as defined in the [RFC 2616](https://www.ietf.org/rfc/rfc2616.txt) and [RFC 6585](https://www.ietf.org/rfc/rfc6585.txt):
| Status Code | Description |
| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 200 | OK - The request has succeeded. The client can read the result of the request in the body and the headers of the response. |
| 201 | Created - The request has been fulfilled and resulted in a new resource being created. |
| 202 | Accepted - The request has been accepted for processing, but the processing has not been completed. |
| 204 | No Content - The request has succeeded but returns no message body. |
| 304 | Not Modified. [See Conditional requests](page:concepts/api-calls#conditional-requests). |
| 400 | Bad Request - The request could not be understood by the server due to malformed syntax. The message body will contain more information. |
| 401 | Unauthorized - The request requires user authentication or, if the request included authorization credentials, authorization has been refused for those credentials. |
| 403 | Forbidden - The server understood the request, but is refusing to fulfill it. |
| 404 | Not Found - The requested resource could not be found. This error can be due to a temporary or permanent condition. |
| 429 | Too Many Requests - Rate limiting has been applied. |
| 500 | Internal Server Error. You should never receive this error because our clever coders catch them all ... but if you are unlucky enough to get one, please report it to us through a comment at the bottom of this page. |
| 502 | Bad Gateway - The server was acting as a gateway or proxy and received an invalid response from the upstream server. |
| 503 | Service Unavailable - The server is currently unable to handle the request due to a temporary condition which will be alleviated after some delay. You can choose to resend the request again. |
#### Response Error
Web API uses two different formats to describe an error:
- Authentication Error Object
- Regular Error Object
### Authentication Error Object
Whenever the application makes requests related to authentication or authorization to Web API, such as retrieving an access token or refreshing an access token, the error response follows [RFC 6749](https://tools.ietf.org/html/rfc6749) on the OAuth 2.0 Authorization Framework.
| Key | Value Type | Value Description |
| ----------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| error | string | A high level description of the error as specified in [RFC 6749 Section 5.2.](https://tools.ietf.org/html/rfc6749#section-5.2) |
| error_description | string | A more detailed description of the error as specified in [RFC 6749 Section 4.1.2.1.](https://tools.ietf.org/html/rfc6749#section-4.1.2.1) |
Here is an example of a failing request to refresh an access token.
```bash
$ curl -H "Authorization: Basic Yjc...cK" -d grant_type=refresh_token -d refresh_token=AQD...f0 "https://accounts.spotify.com/api/token"
{
"error": "invalid_client",
"error_description": "Invalid client secret"
}
```
### Regular Error Object
Apart from the response code, unsuccessful responses return a JSON object containing the following information:
| Key | Value Type | Value Description |
| ------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status | integer | The HTTP status code that is also returned in the response header. For further information, see [Response Status Codes](page:concepts/api-calls#response-status-codes). |
| message | string | A short description of the cause of the error. |
Here, for example is the error that occurs when trying to fetch information for a non-existent track:
```bash
$ curl -i "https://api.spotify.com/v1/tracks/2KrxsD86ARO5beq7Q0Drfqa"
HTTP/1.1 400 Bad Request
{
"error": {
"status": 400,
"message": "invalid id"
}
}
```
## Conditional Requests
Most API responses contain appropriate cache-control headers set to assist in client-side caching:
- If you have cached a response, do not request it again until the response has expired.
- If the response contains an ETag, set the If-None-Match request header to the ETag value.
- If the response has not changed, the Spotify service responds quickly with **304 Not Modified** status, meaning that your cached version is still good and your application should use it.
## Timestamps
Timestamps are returned in [ISO 8601](http://en.wikipedia.org/wiki/ISO_8601) format as [Coordinated Universal Time (UTC)](https://en.wikipedia.org/wiki/UTC_offset) with a zero offset: YYYY-MM-DDTHH:MM:SSZ. If the time is imprecise (for example, the date/time of an album release), an additional field indicates the precision; see for example, release_date in an [Album Object]($m/AlbumObject).
## Pagination
Some endpoints support a way of paging the dataset, taking an offset and limit as query parameters:
```bash
$ curl
https://api.spotify.com/v1/artists/1vCWHaC5f2uS3yhpwWbIA6/albums?album_type=SINGLE&offset=20&limit=10
```
In this example, in a list of 50 (total) singles by the specified artist : From the twentieth (offset) single, retrieve the next 10 (limit) singles.
# Apps
The app provides, among others, the Client ID and Client Secret needed to implement any of the authorization flows.
To do so, go to your [Dashboard](https://developer.spotify.com/dashboard) and click on the Create an App button to open the following dialog box:

Enter an *App Name* and *App Description* of your choice (they will be displayed to the user on the grant screen), put a tick in the *Developer Terms of Service checkbox* and finally click on *CREATE*. Your application is now registered, and you'll be redirected to the app overview page.

The app overview page provides access to different elements:
- App metrics, such as daily and monthly active users or number of users per country. Note that the metrics are initially empty.
- App Status. By default, your app will be in Development Mode with limits on the number of users who can install it, and the number of API requests it can make. Note that you can request an extension of this quota if needed by clicking on the Request Extension link.
- App settings.
- Client ID, the unique identifier of your app.
- Client Secret, the key you will use to authorize your Web API or SDK calls.
> Always store the client secret key securely; never reveal it publicly! If you suspect that the secret key has been compromised, regenerate it immediately by clicking the ROTATE button on the app overview page.
It is time to configure our app. Click on Edit Settings to view and update your app settings. The following dialog will show up:

- Add a web domain or URL to the Website field. This will help users to obtain more information about your application.
- In Redirect URIs enter one or more addresses that you want to allowlist with Spotify. This URI enables the Spotify authentication service to automatically invoke your app every time the user logs in (e.g. [http://localhost:8080](http://localhost:8080))
Note that on iOS apps, the redirect URI must follow these rules:
- All the characters are lowercase.
- The prefix must be unique to your application (It cannot be a general prefix like http).
- The prefix must only be used by your application for authenticating Spotify. If you already have a URL scheme handled by your application for other uses, do not reuse it.
- Include a path after the first pair of forward slashes.
For example: If your app name is My Awesome App, a good candidate for the redirect URI could be my-awesome-app-login://callback.
- If you are developing an Android or iOS app, fill out the Android Package or Bundle IDs respectively.
Once you have finished updating the app settings, click on SAVE.
Finally, you can delete your app by clicking on the DELETE red button.
# Authorization
Authorization refers to the process of granting a user or application access permissions to Spotify data and features (e.g your application needs permission from a user to access their playlists).
Spotify implements the [OAuth 2.0](https://datatracker.ietf.org/doc/html/rfc6749) authorization framework:

Where:
- End User corresponds to the Spotify user. The End User grants access to the protected resources (e.g. playlists, personal information, etc.)
- My App is the client that requests access to the protected resources (e.g. a mobile or web app).
- Server which hosts the protected resources and provides authentication and authorization via OAuth 2.0.
The access to the protected resources is determined by one or several scopes. Scopes enable your application to access specific functionality (e.g. read a playlist, modify your library or just streaming) on behalf of a user. The set of scopes you set during the authorization, determines the access permissions that the user is asked to grant. You can find detailed information about scopes in the [scopes documentation](page:concepts/scopes).
The authorization process requires valid client credentials: a client ID and a client secret. You can follow the [Apps guide](page:concepts/apps) to learn how to generate them.
Once the authorization is granted, the authorization server issues an access token, which is used to make API calls on behalf the user or application.
# Scopes
Scopes provide Spotify users using third-party apps the confidence that only the information they choose to share will be shared, and nothing more.
## Pre-requisites
Scopes are needed when implementing some of the [authorization](page:concepts/authorization) grant types. Make sure you have read the Authorization guide to understand the basics.
## List of Scopes
- Images
- [ugc-image-upload](page:concepts/scopes#ugc-image-upload)
- Spotify Connect
- [user-read-playback-state](page:concepts/scopes#user-read-playback-state)
- [user-modify-playback-state](page:concepts/scopes#user-modify-playback-state)
- [user-read-currently-playing](page:concepts/scopes#user-read-currently-playing)
- Playback
- [app-remote-control](page:concepts/scopes#app-remote-control)
- [streaming](page:concepts/scopes#streaming)
- Playlists
- [playlist-read-private](page:concepts/scopes#playlist-read-private)
- [playlist-read-collaborative](page:concepts/scopes#playlist-read-collaborative)
- [playlist-modify-private](page:concepts/scopes#playlist-modify-private)
- [playlist-modify-public](page:concepts/scopes#playlist-modify-public)
- Follow
- [user-follow-modify](page:concepts/scopes#user-follow-modify)
- [user-follow-read](page:concepts/scopes#user-follow-read)
- Listening History
- [user-read-playback-position](page:concepts/scopes#user-read-playback-position)
- [user-top-read](page:concepts/scopes#user-top-read)
- [user-read-recently-played](page:concepts/scopes#user-read-recently-played)
- Library
- [user-library-modify](page:concepts/scopes#user-library-modify)
- [user-library-read](page:concepts/scopes#user-library-read)
- Users
- [user-read-email](page:concepts/scopes#user-read-email)
- [user-read-private](page:concepts/scopes#user-read-private)
- Open Access
- [user-soa-link](page:concepts/scopes#user-soa-link)
- [user-soa-unlink](page:concepts/scopes#user-soa-unlink)
- [soa-manage-entitlements](page:concepts/scopes#soa-manage-entitlements)
- [soa-manage-partner](page:concepts/scopes#soa-manage-partner)
- [soa-create-partner](page:concepts/scopes#soa-create-partner)
## ugc-image-upload
| Description | Write access to user-provided images. |
| Visible to users | Upload images to Spotify on your behalf. |
## user-read-playback-state
| Description | Read access to a user’s player state. |
| Visible to users | Read your currently playing content and Spotify Connect devices information. |
## user-modify-playback-state
| Description | Write access to a user’s playback state |
| Visible to users | Control playback on your Spotify clients and Spotify Connect devices. |
## user-read-currently-playing
| Description | Read access to a user’s currently playing content. |
| Visible to users | Read your currently playing content. |
## app-remote-control
| Description |Remote control playback of Spotify. This scope is currently available to Spotify iOS and Android SDKs. |
| Visible to users | Communicate with the Spotify app on your device. |
## streaming
| Description | Control playback of a Spotify track. This scope is currently available to the Web Playback SDK. The user must have a Spotify Premium account. |
| Visible to users | Play content and control playback on your other devices. |
## playlist-read-private
| Description | Read access to user's private playlists. |
| Visible to users | Access your private playlists. |
## playlist-read-collaborative
| Description | Include collaborative playlists when requesting a user's playlists. |
| Visible to users | Access your collaborative playlists. |
## playlist-modify-private
| Description | Write access to a user's private playlists. |
| Visible to users | Manage your private playlists.
## playlist-modify-public
| Description | Write access to a user's public playlists.|
| Visible to users | Manage your public playlists.|
## user-follow-modify
| Description | Write/delete access to the list of artists and other users that the user follows. |
| Visible to users | Manage who you are following. |
## user-follow-read
| Description | Read access to the list of artists and other users that the user follows. |
| Visible to users | Access your followers and who you are following. |
## user-read-playback-position
| Description | Read access to a user’s playback position in a content. |
| Visible to users | Read your position in content you have played. |
## user-top-read
| Description | Read access to a user's top artists and tracks. |
| Visible to users | Read your top artists and content. |
## user-read-recently-played
| Description | Read access to a user’s recently played tracks. |
| Visible to users | Access your recently played items. |
## user-library-modify
| Description | Write/delete access to a user's "Your Music" library. |
| Visible to users | Manage your saved content. |
## user-library-read
| Description | Read access to a user's library. |
| Visible to users | Access your saved content. |
## user-read-email
| Description | Read access to user’s email address. |
| Visible to users | Get your real email address. |
## user-read-private
| Description | Read access to user’s subscription details (type of user account). |
| Visible to users | Access your subscription details. |
## user-soa-link
| Description | Link a partner user account to a Spotify user account |
## user-soa-unlink
| Description | Unlink a partner user account from a Spotify account |
## soa-manage-entitlements
| Description | Modify entitlements for linked users |
## soa-manage-partner
| Description | Update partner information |
## soa-create-partner
| Description | Create new partners, platform partners only |
# Spotify URIs and IDs
In requests to the Web API and responses from it, you will frequently encounter the following parameters:
## Spotify URI
The resource identifier of, for example, an artist, album or track. This can be entered in the search box in a Spotify Desktop Client, to navigate to that resource. To find a Spotify URI, right-click (on Windows) or Ctrl-Click (on a Mac) on the artist, album or track name.
Example: `spotify:track:6rqhFgbbKwnb9MLmUQDhG6`
## Spotify ID
The base-62 identifier found at the end of the Spotify URI (see above) for an artist, track, album, playlist, etc. Unlike a Spotify URI, a Spotify ID does not clearly identify the type of resource; that information is provided elsewhere in the call.
Example: `6rqhFgbbKwnb9MLmUQDhG6`
## Spotify category ID
The unique string identifying the Spotify category.
Example: `party`
## Spotify user ID
The unique string identifying the Spotify user that you can find at the end of the Spotify URI for the user. The ID of the current user can be obtained via the [Get Current User's Profile endpoint]($e/Users/get-current-users-profile).
Example: `wizzler`
## Spotify URL
When visited, if the user has the Spotify client installed, it will launch the Client and navigate to the requested resource. Which client is determined by the user's device and account settings at [play.spotify.com](page:play.spotify.com).
Example: `http://open.spotify.com/track/6rqhFgbbKwnb9MLmUQDhG6`
# Authorization Code Flow
The authorization code flow is suitable for long-running applications (e.g. web and mobile apps) where the user grants permission only once.
If you’re using the authorization code flow in a mobile app, or any other type of application where the client secret can't be safely stored, then you should use the PKCE extension. Keep reading to learn how to correctly implement it.
The following diagram shows how the authorization code flow works:

## Pre-requisites
This guide assumes that:
- You have read the [authorization guide](page:concepts/authorization).
- You have created an app following the [apps guide](page:concepts/apps).
### Example
You can find an example app implementing Authorization Code flow on GitHub in the [web-api-examples](https://github.com/spotify/web-api-examples/tree/master/authorization/authorization_code) repository.
## Request User Authorization
The first step is to request authorization from the user so that our app can access to the Spotify resources on the user's behalf. To do this, our application must build and send a GET request to the /authorize endpoint with the following parameters:
| Query Parameter | Relevance | Value |
| client_id | Required | The Client ID generated after registering your application. |
| response_type | Required | Set to code. |
| redirect_uri | Required | The URI to redirect to after the user grants or denies permission. This URI needs to have been entered in the Redirect URI allowlist that you specified when you registered your application (See the [app guide](page:concepts/apps)). The value of redirect_uri here must exactly match one of the values you entered when you registered your application, including upper or lowercase, terminating slashes, and such. |
| state | Optional, but strongly recommended| This provides protection against attacks such as cross-site request forgery. See [RFC-6749](https://datatracker.ietf.org/doc/html/rfc6749#section-4.1). |
| scope | Optional | A space-separated list of [scopes](page:concepts/scopes).If no scopes are specified, authorization will be granted only to access publicly available information: that is, only information normally visible in the Spotify desktop, web, and mobile players. |
| show_dialog | Optional | Whether or not to force the user to approve the app again if they’ve already done so. If false (default), a user who has already approved the application may be automatically redirected to the URI specified by redirect_uri. If true, the user will not be automatically redirected and will have to approve the app again. |
The following JavaScript code example implements the /login method using [Express](page:Express) framework to initiates the authorization request:
```javascript
var client_id = "CLIENT_ID";
var redirect_uri = "http://localhost:8888/callback";
var app = express();
app.get("/login", function (req, res) {
var state = generateRandomString(16);
var scope = "user-read-private user-read-email";
res.redirect(
"https://accounts.spotify.com/authorize?" +
querystring.stringify({
response_type: "code",
client_id: client_id,
scope: scope,
redirect_uri: redirect_uri,
state: state,
})
);
});
```
Once the request is processed, the user will see the authorization dialog asking to authorize access within the user-read-private and user-read-email scopes.
The Spotify OAuth 2.0 service presents details of the [scopes](page:concepts/scopes) for which access is being sought. If the user is not logged in, they are prompted to do so using their Spotify credentials. When the user is logged in, they are asked to authorize access to the data sets or features defined in the scopes.
Finally, the user is redirected back to your specified `redirect_uri`. After the user accepts, or denies your request, the Spotify OAuth 2.0 service redirects the user back to your `redirect_uri`. In this example, the redirect address is `https://localhost:8888/callback`
### Response for Request User Authorization
If the user accepts your request, then the user is redirected back to the application using the redirect_uri passed on the authorized request described above.
The callback contains two query parameters:
| Query Parameter | Value |
| --------------- | ---------------------------------------------------------------- |
| code | An authorization code that can be exchanged for an access token. |
| state | The value of the state parameter supplied in the request. |
For example:
```bash
https://my-domain.com/callback?code=NApCCg..BkWtQ&state=34fFs29kd09
```
If the user does not accept your request or if an error has occurred, the response query string contains the following parameters:
| Query Parameter | Value |
| --------------- | ------------------------------------------------------------- |
| error | The reason authorization failed, for example: "access_denied" |
| state | The value of the state parameter supplied in the request. |
For example:
```bash
https://my-domain.com/callback?error=access_denied&state=34fFs29kd09
```
In both cases, your app should compare the state parameter that it received in the redirection URI with the state parameter it originally provided to Spotify in the authorization URI. If there is a mismatch then your app should reject the request and stop the authentication flow.
## Request an Access Token
If the user accepted your request, then your app is ready to exchange the authorization code for an access token. It can do this by sending a POST request to the /api/token endpoint.
The body of this POST request must contain the following parameters encoded in application/x-www-form-urlencoded:
| Body Parameters | Relevance | Value |
| --------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| grant_type | Required | This field must contain the value "authorization_code". |
| code | Required | The authorization code returned from the previous request. |
| redirect_uri | Required | This parameter is used for validation only (there is no actual redirection). The value of this parameter must exactly match the value of redirect_uri supplied when requesting the authorization code. |
The request must include the following HTTP headers:
| Header Parameter | Relevance | Value |
| ---------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Authorization | Required | Base 64 encoded string that contains the client ID and client secret key. The field must have the format: Authorization: Basic |
| Content-Type | Required | Set to application/x-www-form-urlencoded. |
This step is usually implemented within the callback described on the request of the previous steps:
```javascript
app.get("/callback", function (req, res) {
var code = req.query.code || null;
var state = req.query.state || null;
if (state === null) {
res.redirect(
"/#" +
querystring.stringify({
error: "state_mismatch",
})
);
} else {
var authOptions = {
url: "https://accounts.spotify.com/api/token",
form: {
code: code,
redirect_uri: redirect_uri,
grant_type: "authorization_code",
},
headers: {
"content-type": "application/x-www-form-urlencoded",
Authorization:
"Basic " +
new Buffer.from(client_id + ":" + client_secret).toString("base64"),
},
json: true,
};
}
});
```
### Response for Request an Access Token
On success, the response will have a 200 OK status and the following JSON data in the response body:
| key | Type | Description |
| ------------- | ------ | -------------------------------------------------------------------------------------------------- |
| access_token | string | An access token that can be provided in subsequent calls, for example to Spotify Web API services. |
| token_type | string | How the access token may be used: always "Bearer". |
| scope | string | A space-separated list of scopes which have been granted for this access_token |
| expires_in | int | The time period (in seconds) for which the access token is valid. |
| refresh_token | string | See [refreshing tokens](page:concepts/scopes). |
## What's next?
- Congratulations! Your fresh access token is ready to be used! How can we make API calls with it? take a look at to the access token guide to learn how to make an API call using your new fresh [access token](page:concepts/access-token).
- If your access token has expired, you can learn how to issue a new one without requiring users to reauthorize your application by reading the [refresh token guide](page:tutorials/refreshing-tokens).
# Refreshing Tokens
A refresh token is a security credential that allows client applications to obtain new access tokens without requiring users to reauthorize the application.
[Access tokens](page:concepts/access-token) are intentionally configured to have a limited lifespan (1 hour), at the end of which, new tokens can be obtained by providing the original refresh token acquired during the authorization token request response:
```json
{
"access_token": "NgCXRK...MzYjw",
"token_type": "Bearer",
"scope": "user-read-private user-read-email",
"expires_in": 3600,
"refresh_token": "NgAagA...Um_SHo"
}
```
## Request
To refresh an access token, we must send a POST request with the following parameters:
| Body Parameter | Relevance | Value |
| -------------- | ------------------------------------ | ------------------------------------------------------------------- |
| grant_type | Required | Set it to refresh_token. |
| refresh_token | Required | The refresh token returned from the authorization token request. |
| client_id | Only required for the PKCE extension | The client ID for your app, available from the developer dashboard. |
And the following headers:
| Header Parameter | Relevance | Value |
| ------------------ | ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Content-Type | Required | Always set to application/x-www-form-urlencoded. |
| Authorization Only | required for the Authorization Code | Base 64 encoded string that contains the client ID and client secret key. The field must have the format: `Authorization: Basic `
### Example
The following code snippets represent two examples:
- A client side (browser) JavaScript function to refresh tokens issued following the Authorization Code with PKCE extension flow.
- A server side (nodeJS with express) Javascript method to refresh tokens issued under the Authorization Code flow.
#### Javascript
```javascript
const getRefreshToken = async () => {
// refresh token that has been previously stored
const refreshToken = localStorage.getItem('refresh_token');
const url = "https://accounts.spotify.com/api/token";
const payload = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
grant_type: 'refresh_token',
refresh_token: refreshToken,
client_id: clientId
}),
}
const body = await fetch(url, payload);
const response await body.json();
localStorage.setItem('access_token', response.accessToken);
localStorage.setItem('refresh_token', response.refreshToken);
}
```
#### NodeJS
```javascript
app.get("/refresh_token", function (req, res) {
var refresh_token = req.query.refresh_token;
var authOptions = {
url: "https://accounts.spotify.com/api/token",
headers: {
"content-type": "application/x-www-form-urlencoded",
Authorization:
"Basic " +
new Buffer.from(client_id + ":" + client_secret).toString("base64"),
},
form: {
grant_type: "refresh_token",
refresh_token: refresh_token,
},
json: true,
};
request.post(authOptions, function (error, response, body) {
if (!error && response.statusCode === 200) {
var access_token = body.access_token,
refresh_token = body.refresh_token;
res.send({
access_token: access_token,
refresh_token: refresh_token,
});
}
});
});
```
### Response
If everything goes well, you'll receive a 200 OK response which is very similar to the response when issuing an access token:
```json
{
"access_token": "BQBLuPRYBQ...BP8stIv5xr-Iwaf4l8eg",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "AQAQfyEFmJJuCvAFh...cG_m-2KTgNDaDMQqjrOa3",
"scope": "user-read-email user-read-private"
}
```
The refresh token contained in the response, could be used to issue new refresh tokens.
# Setting Up SDKs
## Introduction
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 Package
If you are building with .NET CLI tools then you can also use the following command:
```bash
dotnet add package SpotifyApiSDK --version 1.0.0
```
You can also view the package at:
https://www.nuget.org/packages/SpotifyApiSDK/1.0.0
## Initialize the API Client
The following parameters are configurable for the API Client:
| Parameter | Type | Description |
| --- | --- | --- |
| Environment | `Environment` | The API environment. **Default: `Environment.Production`** |
| Timeout | `TimeSpan` | Http client timeout. *Default*: `TimeSpan.FromSeconds(100)` |
| HttpClientConfiguration | `Action` | Action delegate that configures the HTTP client by using the HttpClientConfiguration.Builder for customizing API call settings. *Default*: `new HttpClient()` |
| AuthorizationCodeAuth | [`AuthorizationCodeAuth`]($h/__auth_AuthorizationCodeAuth) | The Credentials Setter for OAuth 2 Authorization Code Grant |
The API client can be initialized as follows:
```csharp
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.OAuthScopes(
new List
{
OAuthScopeEnum.AppRemoteControl,
OAuthScopeEnum.PlaylistReadPrivate,
})
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
```
## Authorization
This API uses the following authentication schemes.
* [`oauth_2_0 (OAuth 2 Authorization Code Grant)`]($h/__auth_AuthorizationCodeAuth)
### oauth_2_0 (OAuth 2 Authorization Code Grant)
Documentation for accessing and setting credentials for oauth_2_0.
#### Auth Credentials
| Name | Type | Description | Setter | Getter |
| --- | --- | --- | --- | --- |
| OAuthClientId | `string` | OAuth 2 Client ID | `OAuthClientId` | `OAuthClientId` |
| OAuthClientSecret | `string` | OAuth 2 Client Secret | `OAuthClientSecret` | `OAuthClientSecret` |
| OAuthRedirectUri | `string` | OAuth 2 Redirection endpoint or Callback Uri | `OAuthRedirectUri` | `OAuthRedirectUri` |
| OAuthToken | `Models.OAuthToken` | Object for storing information about the OAuth token | `OAuthToken` | `OAuthToken` |
| OAuthScopes | `List` | List of scopes that apply to the OAuth token | `OAuthScopes` | `OAuthScopes` |
**Note:** Auth credentials can be set using `AuthorizationCodeAuth` in the client builder and accessed through `AuthorizationCodeAuth` method in the client instance.
#### 1\. Client Initialization
You must initialize the client with *OAuth 2.0 Authorization Code Grant* credentials as shown in the following code snippet.
```csharp
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.OAuthScopes(
new List
{
OAuthScopeEnum.AppRemoteControl,
OAuthScopeEnum.PlaylistReadPrivate,
})
.Build())
.Build();
```
Your application must obtain user authorization before it can execute an endpoint call in case this SDK chooses to use *OAuth 2.0 Authorization Code Grant*. This authorization includes the following steps
#### 2\. Obtain user consent
To obtain user's consent, you must redirect the user to the authorization page.The `BuildAuthorizationUrl()` method creates the URL to the authorization page. You must have initialized the client with scopes for which you need permission to access.
```csharp
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
```
#### 3\. Handle the OAuth server response
Once the user responds to the consent request, the OAuth 2.0 server responds to your application's access request by redirecting the user to the redirect URI specified set in `Configuration`.
If the user approves the request, the authorization code will be sent as the `code` query string:
```
https://example.com/oauth/callback?code=XXXXXXXXXXXXXXXXXXXXXXXXX
```
If the user does not approve the request, the response contains an `error` query string:
```
https://example.com/oauth/callback?error=access_denied
```
#### 4\. Authorize the client using the code
After the server receives the code, it can exchange this for an *access token*. The access token is an object containing information for authorizing client requests and refreshing the token itself.
```csharp
var authManager = client.AuthorizationCodeAuth;
try
{
OAuthToken token = authManager.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (ApiException e)
{
// TODO Handle exception
}
```
#### Scopes
Scopes enable your application to only request access to the resources it needs while enabling users to control the amount of access they grant to your application. Available scopes are defined in the [`OAuthScopeEnum`]($m/OAuth%20Scope) enumeration.
| Scope Name | Description |
| --- | --- |
| `APP-REMOTE-CONTROL` | Communicate with the Spotify app on your device. |
| `PLAYLIST-READ-PRIVATE` | Access your private playlists. |
| `PLAYLIST-READ-COLLABORATIVE` | Access your collaborative playlists. |
| `PLAYLIST-MODIFY-PUBLIC` | Manage your public playlists. |
| `PLAYLIST-MODIFY-PRIVATE` | Manage your private playlists. |
| `USER-LIBRARY-READ` | Access your saved content. |
| `USER-LIBRARY-MODIFY` | Manage your saved content. |
| `USER-READ-PRIVATE` | Access your subscription details. |
| `USER-READ-EMAIL` | Get your real email address. |
| `USER-FOLLOW-READ` | Access your followers and who you are following. |
| `USER-FOLLOW-MODIFY` | Manage your saved content. |
| `USER-TOP-READ` | Read your top artists and content. |
| `USER-READ-PLAYBACK-POSITION` | Read your position in content you have played. |
| `USER-READ-PLAYBACK-STATE` | Read your currently playing content and Spotify Connect devices information. |
| `USER-READ-RECENTLY-PLAYED` | Access your recently played items. |
| `USER-READ-CURRENTLY-PLAYING` | Read your currently playing content. |
| `USER-MODIFY-PLAYBACK-STATE` | Control playback on your Spotify clients and Spotify Connect devices. |
| `UGC-IMAGE-UPLOAD` | Upload images to Spotify on your behalf. |
| `STREAMING` | Play content and control playback on your other devices. |
#### Refreshing the token
An access token may expire after sometime. To extend its lifetime, you must refresh the token.
```csharp
if (authManager.IsTokenExpired())
{
try
{
OAuthToken token = authManager.RefreshToken();
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (ApiException e)
{
// TODO Handle exception
}
}
```
If a token expires, an exception will be thrown before the next endpoint call requiring authentication.
#### Storing an access token for reuse
It is recommended that you store the access token for reuse.
```csharp
// store token
SaveTokenToDatabase(client.AuthorizationCodeAuth.OAuthToken);
```
#### Creating a client from a stored token
To authorize a client using a stored access token, just set the access token in Configuration along with the other configuration parameters before creating the client:
```csharp
// load token later
OAuthToken token = LoadTokenFromDatabase();
// re-instantiate the client with OAuth token
SpotifyWebAPIClient client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
```
#### Complete example
```csharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Models;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Authentication;
using System.Collections.Generic;
namespace OAuthTestApplication
{
class Program
{
static void Main(string[] args)
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.OAuthScopes(
new List
{
OAuthScopeEnum.AppRemoteControl,
OAuthScopeEnum.PlaylistReadPrivate,
})
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
try
{
OAuthToken token = LoadTokenFromDatabase();
// Set the token if it is not set before
if (token == null)
{
var authManager = client.AuthorizationCodeAuth;
string authUrl = await authManager.BuildAuthorizationUrl();
string authorizationCode = GetAuthorizationCode(authUrl);
token = authManager.FetchToken(authorizationCode);
}
SaveTokenToDatabase(token);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (OAuthProviderException e)
{
// TODO Handle exception
}
}
private static string GetAuthorizationCode(string authUrl)
{
// TODO Open the given auth URL, give access and return authorization code from redirect URL
return string.Empty;
}
private static void SaveTokenToDatabase(OAuthToken token)
{
//Save token here
}
private static OAuthToken LoadTokenFromDatabase()
{
OAuthToken token = null;
//token = Get token here
return token;
}
}
}
// the client is now authorized and you can use controllers to make endpoint calls
```
# API Endpoints
## Albums
### get-an-album
Get Spotify catalog information for a single album.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
AlbumsController albumsController = client.AlbumsController;
string id = "4aawyAB9vmqN3uQ7FjRGTy";
string market = "ES";
try
{
ApiResponse result = await albumsController.GetAnAlbumAsync(
id,
market
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- id (`string`)
- market (`string`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): An album
### get-multiple-albums
Get Spotify catalog information for multiple albums identified by their Spotify IDs.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
AlbumsController albumsController = client.AlbumsController;
string ids = "382ObEPsp2rxGrnsizN5TX,1A2GTWGtFfWp7KSQTwWOyo,2noRn2Aes5aoNVsU6iWThc";
string market = "ES";
try
{
ApiResponse result = await albumsController.GetMultipleAlbumsAsync(
ids,
market
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- ids (`string`)
- market (`string`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): A set of albums
### get-an-albums-tracks
Get Spotify catalog information about an album’s tracks.
Optional parameters can be used to limit the number of tracks returned.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
AlbumsController albumsController = client.AlbumsController;
string id = "4aawyAB9vmqN3uQ7FjRGTy";
string market = "ES";
int? limit = 10;
int? offset = 5;
try
{
ApiResponse result = await albumsController.GetAnAlbumsTracksAsync(
id,
market,
limit,
offset
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- id (`string`)
- market (`string`)
- limit (`int?`)
- offset (`int?`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): Pages of tracks
### get-users-saved-albums
Get a list of the albums saved in the current Spotify user's 'Your Music' library.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.OAuthScopes(
new List
{
OAuthScopeEnum.UserLibraryRead,
})
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
AlbumsController albumsController = client.AlbumsController;
int? limit = 10;
int? offset = 5;
string market = "ES";
try
{
ApiResponse result = await albumsController.GetUsersSavedAlbumsAsync(
limit,
offset,
market
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- limit (`int?`)
- offset (`int?`)
- market (`string`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): Pages of albums
### save-albums-user
Save one or more albums to the current user's 'Your Music' library.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.OAuthScopes(
new List
{
OAuthScopeEnum.UserLibraryModify,
})
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
AlbumsController albumsController = client.AlbumsController;
string ids = "382ObEPsp2rxGrnsizN5TX,1A2GTWGtFfWp7KSQTwWOyo,2noRn2Aes5aoNVsU6iWThc";
try
{
await albumsController.SaveAlbumsUserAsync(ids);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- ids (`string`)
- body (`MeAlbumsRequest`)
#### Response Type
- Task
#### Response Properties
- response (`Task`): The album is saved
### remove-albums-user
Remove one or more albums from the current user's 'Your Music' library.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.OAuthScopes(
new List
{
OAuthScopeEnum.UserLibraryModify,
})
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
AlbumsController albumsController = client.AlbumsController;
string ids = "382ObEPsp2rxGrnsizN5TX,1A2GTWGtFfWp7KSQTwWOyo,2noRn2Aes5aoNVsU6iWThc";
try
{
await albumsController.RemoveAlbumsUserAsync(ids);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- ids (`string`)
- body (`MeAlbumsRequest`)
#### Response Type
- Task
#### Response Properties
- response (`Task`): Album(s) have been removed from the library
### check-users-saved-albums
Check if one or more albums is already saved in the current Spotify user's 'Your Music' library.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.OAuthScopes(
new List
{
OAuthScopeEnum.UserLibraryRead,
})
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
AlbumsController albumsController = client.AlbumsController;
string ids = "382ObEPsp2rxGrnsizN5TX,1A2GTWGtFfWp7KSQTwWOyo,2noRn2Aes5aoNVsU6iWThc";
try
{
ApiResponse> result = await albumsController.CheckUsersSavedAlbumsAsync(ids);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- ids (`string`)
#### Response Type
- Task>>
#### Response Properties
- response (`Task>>`): Array of booleans
### get-new-releases
Get a list of new album releases featured in Spotify (shown, for example, on a Spotify player’s “Browse” tab).
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
AlbumsController albumsController = client.AlbumsController;
int? limit = 10;
int? offset = 5;
try
{
ApiResponse result = await albumsController.GetNewReleasesAsync(
limit,
offset
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- limit (`int?`)
- offset (`int?`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): A paged set of albums
## Artists
### get-an-artist
Get Spotify catalog information for a single artist identified by their unique Spotify ID.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
ArtistsController artistsController = client.ArtistsController;
string id = "0TnOYISbd1XYRBk9myaseg";
try
{
ApiResponse result = await artistsController.GetAnArtistAsync(id);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- id (`string`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): An artist
### get-multiple-artists
Get Spotify catalog information for several artists based on their Spotify IDs.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
ArtistsController artistsController = client.ArtistsController;
string ids = "2CIMQHirSU0MQqyYHq0eOx,57dN52uHvrHOxijzpIgu3E,1vCWHaC5f2uS3yhpwWbIA6";
try
{
ApiResponse result = await artistsController.GetMultipleArtistsAsync(ids);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- ids (`string`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): A set of artists
### get-an-artists-albums
Get Spotify catalog information about an artist's albums.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
ArtistsController artistsController = client.ArtistsController;
string id = "0TnOYISbd1XYRBk9myaseg";
string includeGroups = "single,appears_on";
string market = "ES";
int? limit = 10;
int? offset = 5;
try
{
ApiResponse result = await artistsController.GetAnArtistsAlbumsAsync(
id,
includeGroups,
market,
limit,
offset
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- id (`string`)
- includeGroups (`string`)
- market (`string`)
- limit (`int?`)
- offset (`int?`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): Pages of albums
### get-an-artists-top-tracks
Get Spotify catalog information about an artist's top tracks by country.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
ArtistsController artistsController = client.ArtistsController;
string id = "0TnOYISbd1XYRBk9myaseg";
string market = "ES";
try
{
ApiResponse result = await artistsController.GetAnArtistsTopTracksAsync(
id,
market
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- id (`string`)
- market (`string`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): A set of tracks
### get-an-artists-related-artists
Get Spotify catalog information about artists similar to a given artist. Similarity is based on analysis of the Spotify community's listening history.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
ArtistsController artistsController = client.ArtistsController;
string id = "0TnOYISbd1XYRBk9myaseg";
try
{
ApiResponse result = await artistsController.GetAnArtistsRelatedArtistsAsync(id);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- id (`string`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): A set of artists
## Audiobooks
### get-an-audiobook
Get Spotify catalog information for a single audiobook. Audiobooks are only available within the US, UK, Canada, Ireland, New Zealand and Australia markets.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
AudiobooksController audiobooksController = client.AudiobooksController;
string id = "7iHfbu1YPACw6oZPAFJtqe";
string market = "ES";
try
{
ApiResponse result = await audiobooksController.GetAnAudiobookAsync(
id,
market
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- id (`string`)
- market (`string`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): An Audiobook
### get-multiple-audiobooks
Get Spotify catalog information for several audiobooks identified by their Spotify IDs. Audiobooks are only available within the US, UK, Canada, Ireland, New Zealand and Australia markets.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
AudiobooksController audiobooksController = client.AudiobooksController;
string ids = "18yVqkdbdRvS24c0Ilj2ci,1HGw3J3NxZO1TP1BTtVhpZ,7iHfbu1YPACw6oZPAFJtqe";
string market = "ES";
try
{
ApiResponse result = await audiobooksController.GetMultipleAudiobooksAsync(
ids,
market
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- ids (`string`)
- market (`string`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): A set of audiobooks. If one of the requested audiobooks is unavailable then you'll find a `null` item in the `audiobooks` array where the audiobook object would otherwise be.
### get-audiobook-chapters
Get Spotify catalog information about an audiobook's chapters. Audiobooks are only available within the US, UK, Canada, Ireland, New Zealand and Australia markets.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
AudiobooksController audiobooksController = client.AudiobooksController;
string id = "7iHfbu1YPACw6oZPAFJtqe";
string market = "ES";
int? limit = 10;
int? offset = 5;
try
{
ApiResponse result = await audiobooksController.GetAudiobookChaptersAsync(
id,
market,
limit,
offset
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- id (`string`)
- market (`string`)
- limit (`int?`)
- offset (`int?`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): Pages of chapters
### get-users-saved-audiobooks
Get a list of the audiobooks saved in the current Spotify user's 'Your Music' library.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.OAuthScopes(
new List
{
OAuthScopeEnum.UserLibraryRead,
})
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
AudiobooksController audiobooksController = client.AudiobooksController;
int? limit = 10;
int? offset = 5;
try
{
ApiResponse result = await audiobooksController.GetUsersSavedAudiobooksAsync(
limit,
offset
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- limit (`int?`)
- offset (`int?`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): Pages of saved audiobooks
### save-audiobooks-user
Save one or more audiobooks to the current Spotify user's library.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.OAuthScopes(
new List
{
OAuthScopeEnum.UserLibraryModify,
})
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
AudiobooksController audiobooksController = client.AudiobooksController;
string ids = "18yVqkdbdRvS24c0Ilj2ci,1HGw3J3NxZO1TP1BTtVhpZ,7iHfbu1YPACw6oZPAFJtqe";
try
{
await audiobooksController.SaveAudiobooksUserAsync(ids);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- ids (`string`)
#### Response Type
- Task
#### Response Properties
- response (`Task`): Audiobook(s) are saved to the library
### remove-audiobooks-user
Remove one or more audiobooks from the Spotify user's library.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.OAuthScopes(
new List
{
OAuthScopeEnum.UserLibraryModify,
})
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
AudiobooksController audiobooksController = client.AudiobooksController;
string ids = "18yVqkdbdRvS24c0Ilj2ci,1HGw3J3NxZO1TP1BTtVhpZ,7iHfbu1YPACw6oZPAFJtqe";
try
{
await audiobooksController.RemoveAudiobooksUserAsync(ids);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- ids (`string`)
#### Response Type
- Task
#### Response Properties
- response (`Task`): Audiobook(s) have been removed from the library
### check-users-saved-audiobooks
Check if one or more audiobooks are already saved in the current Spotify user's library.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.OAuthScopes(
new List
{
OAuthScopeEnum.UserLibraryRead,
})
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
AudiobooksController audiobooksController = client.AudiobooksController;
string ids = "18yVqkdbdRvS24c0Ilj2ci,1HGw3J3NxZO1TP1BTtVhpZ,7iHfbu1YPACw6oZPAFJtqe";
try
{
ApiResponse> result = await audiobooksController.CheckUsersSavedAudiobooksAsync(ids);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- ids (`string`)
#### Response Type
- Task>>
#### Response Properties
- response (`Task>>`): Array of booleans
## Categories
### get-categories
Get a list of categories used to tag items in Spotify (on, for example, the Spotify player’s “Browse” tab).
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
CategoriesController categoriesController = client.CategoriesController;
string locale = "sv_SE";
int? limit = 10;
int? offset = 5;
try
{
ApiResponse result = await categoriesController.GetCategoriesAsync(
locale,
limit,
offset
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- locale (`string`)
- limit (`int?`)
- offset (`int?`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): A paged set of categories
### get-a-category
Get a single category used to tag items in Spotify (on, for example, the Spotify player’s “Browse” tab).
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
CategoriesController categoriesController = client.CategoriesController;
string categoryId = "dinner";
string locale = "sv_SE";
try
{
ApiResponse result = await categoriesController.GetACategoryAsync(
categoryId,
locale
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- categoryId (`string`)
- locale (`string`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): A category
## Chapters
### get-a-chapter
Get Spotify catalog information for a single audiobook chapter. Chapters are only available within the US, UK, Canada, Ireland, New Zealand and Australia markets.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
ChaptersController chaptersController = client.ChaptersController;
string id = "0D5wENdkdwbqlrHoaJ9g29";
string market = "ES";
try
{
ApiResponse result = await chaptersController.GetAChapterAsync(
id,
market
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- id (`string`)
- market (`string`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): A Chapter
### get-several-chapters
Get Spotify catalog information for several audiobook chapters identified by their Spotify IDs. Chapters are only available within the US, UK, Canada, Ireland, New Zealand and Australia markets.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
ChaptersController chaptersController = client.ChaptersController;
string ids = "0IsXVP0JmcB2adSE338GkK,3ZXb8FKZGU0EHALYX6uCzU,0D5wENdkdwbqlrHoaJ9g29";
string market = "ES";
try
{
ApiResponse result = await chaptersController.GetSeveralChaptersAsync(
ids,
market
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- ids (`string`)
- market (`string`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): A set of chapters
## Episodes
### get-an-episode
Get Spotify catalog information for a single episode identified by its
unique Spotify ID.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.OAuthScopes(
new List
{
OAuthScopeEnum.UserReadPlaybackPosition,
})
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
EpisodesController episodesController = client.EpisodesController;
string id = "512ojhOuo1ktJprKbVcKyQ";
string market = "ES";
try
{
ApiResponse result = await episodesController.GetAnEpisodeAsync(
id,
market
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- id (`string`)
- market (`string`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): An episode
### get-multiple-episodes
Get Spotify catalog information for several episodes based on their Spotify IDs.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.OAuthScopes(
new List
{
OAuthScopeEnum.UserReadPlaybackPosition,
})
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
EpisodesController episodesController = client.EpisodesController;
string ids = "77o6BIVlYM3msb4MMIL1jH,0Q86acNRm6V9GYx55SXKwf";
string market = "ES";
try
{
ApiResponse result = await episodesController.GetMultipleEpisodesAsync(
ids,
market
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- ids (`string`)
- market (`string`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): A set of episodes
### get-users-saved-episodes
Get a list of the episodes saved in the current Spotify user's library.
This API endpoint is in __beta__ and could change without warning. Please share any feedback that you have, or issues that you discover, in our [developer community forum](https://community.spotify.com/t5/Spotify-for-Developers/bd-p/Spotify_Developer).
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.OAuthScopes(
new List
{
OAuthScopeEnum.UserLibraryRead,
OAuthScopeEnum.UserReadPlaybackPosition,
})
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
EpisodesController episodesController = client.EpisodesController;
string market = "ES";
int? limit = 10;
int? offset = 5;
try
{
ApiResponse result = await episodesController.GetUsersSavedEpisodesAsync(
market,
limit,
offset
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- market (`string`)
- limit (`int?`)
- offset (`int?`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): Pages of episodes
### save-episodes-user
Save one or more episodes to the current user's library.
This API endpoint is in __beta__ and could change without warning. Please share any feedback that you have, or issues that you discover, in our [developer community forum](https://community.spotify.com/t5/Spotify-for-Developers/bd-p/Spotify_Developer).
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.OAuthScopes(
new List
{
OAuthScopeEnum.UserLibraryModify,
})
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
EpisodesController episodesController = client.EpisodesController;
string ids = "77o6BIVlYM3msb4MMIL1jH,0Q86acNRm6V9GYx55SXKwf";
try
{
await episodesController.SaveEpisodesUserAsync(ids);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- ids (`string`)
- body (`MeEpisodesRequest`)
#### Response Type
- Task
#### Response Properties
- response (`Task`): Episode saved
### remove-episodes-user
Remove one or more episodes from the current user's library.
This API endpoint is in __beta__ and could change without warning. Please share any feedback that you have, or issues that you discover, in our [developer community forum](https://community.spotify.com/t5/Spotify-for-Developers/bd-p/Spotify_Developer).
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.OAuthScopes(
new List
{
OAuthScopeEnum.UserLibraryModify,
})
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
EpisodesController episodesController = client.EpisodesController;
string ids = "7ouMYWpwJ422jRcDASZB7P,4VqPOruhp5EdPBeR92t6lQ,2takcwOaAZWiXQijPHIx7B";
try
{
await episodesController.RemoveEpisodesUserAsync(ids);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- ids (`string`)
- body (`MeEpisodesRequest1`)
#### Response Type
- Task
#### Response Properties
- response (`Task`): Episode removed
### check-users-saved-episodes
Check if one or more episodes is already saved in the current Spotify user's 'Your Episodes' library.
This API endpoint is in __beta__ and could change without warning. Please share any feedback that you have, or issues that you discover, in our [developer community forum](https://community.spotify.com/t5/Spotify-for-Developers/bd-p/Spotify_Developer)..
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.OAuthScopes(
new List
{
OAuthScopeEnum.UserLibraryRead,
})
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
EpisodesController episodesController = client.EpisodesController;
string ids = "77o6BIVlYM3msb4MMIL1jH,0Q86acNRm6V9GYx55SXKwf";
try
{
ApiResponse> result = await episodesController.CheckUsersSavedEpisodesAsync(ids);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- ids (`string`)
#### Response Type
- Task>>
#### Response Properties
- response (`Task>>`): Array of booleans
## Genres
### get-recommendation-genres
Retrieve a list of available genres seed parameter values for [recommendations](/documentation/web-api/reference/get-recommendations).
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
GenresController genresController = client.GenresController;
try
{
ApiResponse result = await genresController.GetRecommendationGenresAsync();
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): A set of genres
## Markets
### get-available-markets
Get the list of markets where Spotify is available.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
MarketsController marketsController = client.MarketsController;
try
{
ApiResponse result = await marketsController.GetAvailableMarketsAsync();
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): A markets object with an array of country codes
## Player
### get-information-about-the-users-current-playback
Get information about the user’s current playback state, including track or episode, progress, and active device.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.OAuthScopes(
new List
{
OAuthScopeEnum.UserReadPlaybackState,
})
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
PlayerController playerController = client.PlayerController;
string market = "ES";
try
{
ApiResponse result = await playerController.GetInformationAboutTheUsersCurrentPlaybackAsync(market);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- market (`string`)
- additionalTypes (`string`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): Information about playback
### transfer-a-users-playback
Transfer playback to a new device and optionally begin playback. This API only works for users who have Spotify Premium. The order of execution is not guaranteed when you use this API with other Player API endpoints.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.OAuthScopes(
new List
{
OAuthScopeEnum.UserModifyPlaybackState,
})
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
PlayerController playerController = client.PlayerController;
MePlayerRequest body = new MePlayerRequest
{
DeviceIds = new List
{
"74ASZWbe4lXaubB36ztrGX",
},
};
try
{
await playerController.TransferAUsersPlaybackAsync(body);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- body (`MePlayerRequest`)
#### Response Type
- Task
#### Response Properties
- response (`Task`): Playback transferred
### get-a-users-available-devices
Get information about a user’s available Spotify Connect devices. Some device models are not supported and will not be listed in the API response.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.OAuthScopes(
new List
{
OAuthScopeEnum.UserReadPlaybackState,
})
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
PlayerController playerController = client.PlayerController;
try
{
ApiResponse result = await playerController.GetAUsersAvailableDevicesAsync();
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): A set of devices
### get-the-users-currently-playing-track
Get the object currently being played on the user's Spotify account.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Http.Response;
using SpotifyWebAPI.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.OAuthScopes(
new List
{
OAuthScopeEnum.UserReadCurrentlyPlaying,
})
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
PlayerController playerController = client.PlayerController;
string market = "ES";
try
{
ApiResponse result = await playerController.GetTheUsersCurrentlyPlayingTrackAsync(market);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
}
}
}
```
#### Request Parameters
- market (`string`)
- additionalTypes (`string`)
#### Response Type
- Task>
#### Response Properties
- response (`Task>`): Information about the currently playing track
### start-a-users-playback
Start a new context or resume current playback on the user's active device. This API only works for users who have Spotify Premium. The order of execution is not guaranteed when you use this API with other Player API endpoints.
#### Code Sample
```CSharp
using SpotifyWebAPI.Standard;
using SpotifyWebAPI.Standard.Authentication;
using SpotifyWebAPI.Standard.Controllers;
using SpotifyWebAPI.Standard.Exceptions;
using SpotifyWebAPI.Standard.Models;
using SpotifyWebAPI.Standard.Utilities;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
SpotifyWebAPIClient client = new SpotifyWebAPIClient.Builder()
.AuthorizationCodeAuth(
new AuthorizationCodeAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret",
"OAuthRedirectUri"
)
.OAuthScopes(
new List
{
OAuthScopeEnum.UserModifyPlaybackState,
})
.Build())
.Environment(SpotifyWebAPI.Standard.Environment.Production)
.Build();
// Setup the OAuthToken for AuthorizationCodeAuth
try
{
string authUrl = await client.AuthorizationCodeAuth.BuildAuthorizationUrl();
// Redirect user to this authUrl and get a code after the user consent
string authorizationCode = "TODO: Replace Code";
OAuthToken token = client.AuthorizationCodeAuth.FetchToken(authorizationCode);
// re-instantiate the client with OAuth token
client = client.ToBuilder()
.AuthorizationCodeAuth(
client.AuthorizationCodeAuthModel.ToBuilder()
.OAuthToken(token)
.Build())
.Build();
}
catch (Exception e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
PlayerController playerController = client.PlayerController;
string deviceId = "0d1841b0976bae2a3a310dd74c0f3df354899bc8";
MePlayerPlayRequest body = new MePlayerPlayRequest
{
ContextUri = "spotify:album:5ht7ItJgpBH7W6vJ5BqpPr",
Offset = ApiHelper.JsonDeserialize