Spotify.NET/SpotifyAPI.Docs/docs/SpotifyWebAPI/gettingstarted.md

156 lines
5.5 KiB
Markdown
Raw Normal View History

2017-05-31 17:09:45 +01:00
# Getting started
2016-08-20 11:49:09 +01:00
This API provides full access to the new SpotifyWebAPI introduced [here](https://developer.spotify.com/web-api/).
With it, you can search for Tracks/Albums/Artists and also get User-based information.
It's also possible to create new playlists and add tracks to it.
---
2017-05-31 17:09:45 +01:00
## First steps
2016-08-20 11:49:09 +01:00
**Imports**
So after you added the API to your project, you may want to add following imports to your files:
```cs
using SpotifyAPI.Web; //Base Namespace
using SpotifyAPI.Web.Auth; //All Authentication-related classes
using SpotifyAPI.Web.Enums; //Enums
using SpotifyAPI.Web.Models; //Models for the JSON-responses
```
**Basic-Usage**
Now you can actually start doing calls to the SpotifyAPI, just create a new Instance of SpotifyWebAPI:
```cs
private static SpotifyWebAPI _spotify;
public static void Main(String[] args)
{
_spotify = new SpotifyWebAPI()
{
UseAuth = false, //This will disable Authentication.
}
FullTrack track = _spotify.GetTrack("3Hvu1pq89D4R0lyPBoujSv");
Console.WriteLine(track.Name); //Yeay! We just printed a tracks name.
//...
}
```
---
2017-05-31 17:09:45 +01:00
## Authentication
2016-08-20 11:49:09 +01:00
If you look through the available API-Methods, you will soon notice nearly all of them require Authentication.
Further infos on how to implement Authentication can be found [here](/SpotifyWebAPI/auth)
---
2017-05-31 17:09:45 +01:00
## Examples
2016-08-20 11:49:09 +01:00
A list of small examples can be found [here](/SpotifyWebAPI/examples). Do you think a specific example is missing? Feel free to open a PR/Issue!
---
2017-05-31 17:09:45 +01:00
## Error-Handling
2016-08-20 11:49:09 +01:00
Every API-Call returns a reponse-model which consists of base-error model. To check if a specific API-Call was successful, use the following approach:
```cs
PrivateProfile profile = _spotify.GetPrivateProfile();
if (profile.HasError())
{
Console.WriteLine("Error Status: " + profile.Error.Status);
Console.WriteLine("Error Msg: " + profile.Error.Message);
}
```
2017-05-31 17:09:45 +01:00
## Asynchronous
2016-08-20 11:49:09 +01:00
Every API-Call now has an asynchronous method. Just append `Async` to the Method-Name.
Example:
```cs
public async void Test()
{
var profile = await _spotify.GetPrivateProfileAsync();
Console.WriteLine(profile.DisplayName);
}
```
---
2017-05-31 17:09:45 +01:00
## API-Reference
2016-08-20 11:49:09 +01:00
2017-05-31 17:09:45 +01:00
### Albums
2016-08-20 11:49:09 +01:00
* [GetAlbumTracks](/SpotifyWebAPI/albums#getalbumtracks)
* [GetAlbum](/SpotifyWebAPI/albums#getalbum)
* [GetSeveralAlbums](/SpotifyWebAPI/albums#getseveralalbums)
2017-05-31 17:09:45 +01:00
### Artists
2016-08-20 11:49:09 +01:00
* [GetArtist](/SpotifyWebAPI/artists#getartist)
* [GetRelatedArtists](/SpotifyWebAPI/artists#getrelatedartists)
* [GetArtistsTopTracks](/SpotifyWebAPI/artists#getartiststoptracks)
* [GetArtistsAlbums](/SpotifyWebAPI/artists#getartistsalbums)
* [GetSeveralArtists](/SpotifyWebAPI/artists#getseveralartists)
2017-05-31 17:09:45 +01:00
### Browse
2016-08-20 11:49:09 +01:00
* [GetFeaturedPlaylists](/SpotifyWebAPI/browse#getfeaturedplaylists)
* [GetNewAlbumReleases](/SpotifyWebAPI/browse#getnewalbumreleases)
* [GetCategories](/SpotifyWebAPI/browse#getcategories)
* [GetCategory](/SpotifyWebAPI/browse#getcategory)
* [GetCategoryPlaylists](/SpotifyWebAPI/browse#getcategoryplaylists)
2017-05-31 17:09:45 +01:00
### Follow
2016-08-20 11:49:09 +01:00
* [Follow](/SpotifyWebAPI/follow#follow)
* [Unfollow](/SpotifyWebAPI/follow#unfollow)
* [IsFollowing](/SpotifyWebAPI/follow#isfollowing)
* [FollowPlaylist](/SpotifyWebAPI/follow#followplaylist)
* [UnfollowPlaylist](/SpotifyWebAPI/follow#unfollowplaylist)
* [IsFollowingPlaylist](/SpotifyWebAPI/follow#isfollowingplaylist)
2017-05-31 17:09:45 +01:00
### Library
2016-08-20 11:49:09 +01:00
* [SaveTracks](/SpotifyWebAPI/library#savetracks)
* [SaveTrack](/SpotifyWebAPI/library#savetrack)
* [GetSavedTracks](/SpotifyWebAPI/library#getsavedtracks)
* [RemoveSavedTracks](/SpotifyWebAPI/library#removesavedtracks)
* [CheckSavedTracks](/SpotifyWebAPI/library#checksavedtracks)
* [SaveAlbums](/SpotifyWebAPI/library#savealbums)
* [SaveAlbum](/SpotifyWebAPI/library#savealbum)
* [GetSavedAlbums](/SpotifyWebAPI/library#getsavedalbums)
* [RemoveSavedAlbums](/SpotifyWebAPI/library#removesavedalbums)
* [CheckSavedAlbums](/SpotifyWebAPI/library#checksavedalbums)
2017-05-31 17:09:45 +01:00
### Player
* [GetDevices](/SpotifyWebAPI/player#getdevices)
* [GetPlayback](/SpotifyWebAPI/player#getplayback)
* [GetPlayingTrack](/SpotifyWebAPI/player#getplayingtrack)
* [TransferPlayback](/SpotifyWebAPI/player#transferplayback)
* [ResumePlayback](/SpotifyWebAPI/player#resumeplayback)
* [PausePlayback](/SpotifyWebAPI/player#pauseplayback)
* [SkipPlaybackToNext](/SpotifyWebAPI/player#skipplaybacktonext)
* [SkipPlaybackToPrevious](/SpotifyWebAPI/player#skipplaybacktoprevious)
* [SetRepeatMode](/SpotifyWebAPI/player#setrepeatmode)
* [SetVolume](/SpotifyWebAPI/player#setvolume)
* [SetShuffle](/SpotifyWebAPI/player#setshuffle)
### Playlists
2016-08-20 11:49:09 +01:00
* [GetUserPlaylists](/SpotifyWebAPI/playlists#getuserplaylists)
* [GetPlaylist](/SpotifyWebAPI/playlists#getplaylist)
* [GetPlaylistTracks](/SpotifyWebAPI/playlists#getplaylisttracks)
* [CreatePlaylist](/SpotifyWebAPI/playlists#createplaylist)
* [UpdatePlaylist](/SpotifyWebAPI/playlists#updateplaylist)
* [ReplacePlaylistTracks](/SpotifyWebAPI/playlists#replaceplaylisttracks)
* [RemovePlaylistTracks](/SpotifyWebAPI/playlists#removeplaylisttracks)
* [RemovePlaylistTrack](/SpotifyWebAPI/playlists#removeplaylisttrack)
* [AddPlaylistTracks](/SpotifyWebAPI/playlists#addplaylisttracks)
* [AddPlaylistTrack](/SpotifyWebAPI/playlists#addplaylisttrack)
* [ReorderPlaylist](/SpotifyWebAPI/playlists#reorderplaylist)
2017-05-31 17:09:45 +01:00
### Profiles
2016-08-20 11:49:09 +01:00
* [GetPublicProfile](/SpotifyWebAPI/profiles#getpublicprofile)
* [GetPrivateProfile](/SpotifyWebAPI/profiles#getprivateprofile)
2017-05-31 17:09:45 +01:00
### Search
2016-08-20 11:49:09 +01:00
* [SearchItems](/SpotifyWebAPI/search#searchitems)
2017-05-31 17:09:45 +01:00
### Tracks
2016-08-20 11:49:09 +01:00
* [GetSeveralTracks](/SpotifyWebAPI/tracks#getseveraltracks)
* [GetTrack](/SpotifyWebAPI/tracks#gettrack)
2017-05-31 17:09:45 +01:00
### Util
2016-08-20 11:49:09 +01:00
* [Utility-Functions](/SpotifyWebAPI/util)