Spotify.NET/assets/js/67d5074e.48289dc6.js
2021-06-04 19:50:21 +00:00

1 line
18 KiB
JavaScript

(window.webpackJsonp=window.webpackJsonp||[]).push([[24],{124:function(e,t,a){"use strict";a.d(t,"a",(function(){return p})),a.d(t,"b",(function(){return f}));var r=a(0),l=a.n(r);function i(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function s(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,r)}return a}function b(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?s(Object(a),!0).forEach((function(t){i(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):s(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function n(e,t){if(null==e)return{};var a,r,l=function(e,t){if(null==e)return{};var a,r,l={},i=Object.keys(e);for(r=0;r<i.length;r++)a=i[r],t.indexOf(a)>=0||(l[a]=e[a]);return l}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)a=i[r],t.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(l[a]=e[a])}return l}var c=l.a.createContext({}),o=function(e){var t=l.a.useContext(c),a=t;return e&&(a="function"==typeof e?e(t):b(b({},t),e)),a},p=function(e){var t=o(e.components);return l.a.createElement(c.Provider,{value:t},e.children)},u={inlineCode:"code",wrapper:function(e){var t=e.children;return l.a.createElement(l.a.Fragment,{},t)}},d=l.a.forwardRef((function(e,t){var a=e.components,r=e.mdxType,i=e.originalType,s=e.parentName,c=n(e,["components","mdxType","originalType","parentName"]),p=o(a),d=r,f=p["".concat(s,".").concat(d)]||p[d]||u[d]||i;return a?l.a.createElement(f,b(b({ref:t},c),{},{components:a})):l.a.createElement(f,b({ref:t},c))}));function f(e,t){var a=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var i=a.length,s=new Array(i);s[0]=d;var b={};for(var n in t)hasOwnProperty.call(t,n)&&(b[n]=t[n]);b.originalType=e,b.mdxType="string"==typeof e?e:r,s[1]=b;for(var c=2;c<i;c++)s[c]=a[c];return l.a.createElement.apply(null,s)}return l.a.createElement.apply(null,a)}d.displayName="MDXCreateElement"},93:function(e,t,a){"use strict";a.r(t),a.d(t,"frontMatter",(function(){return s})),a.d(t,"metadata",(function(){return b})),a.d(t,"toc",(function(){return n})),a.d(t,"default",(function(){return o}));var r=a(3),l=a(7),i=(a(0),a(124)),s={id:"getting_started",title:"Getting Started",sidebar_label:"Getting Started"},b={unversionedId:"web/getting_started",id:"version-5.1.1/web/getting_started",isDocsHomePage:!1,title:"Getting Started",description:"This API provides full access to the new SpotifyWebAPI introduced here.",source:"@site/versioned_docs/version-5.1.1/web/getting_started.md",slug:"/web/getting_started",permalink:"/SpotifyAPI-NET/docs/5.1.1/web/getting_started",editUrl:"https://github.com/JohnnyCrazy/SpotifyAPI-NET/edit/master/SpotifyAPI.Docs/versioned_docs/version-5.1.1/web/getting_started.md",version:"5.1.1",lastUpdatedBy:"Hashim Qureshi",lastUpdatedAt:1622836122,formattedLastUpdatedAt:"6/4/2021",sidebar_label:"Getting Started",sidebar:"version-5.1.1/someSidebar",previous:{title:"SpotifyAPI-NET",permalink:"/SpotifyAPI-NET/docs/5.1.1/home"},next:{title:"Albums",permalink:"/SpotifyAPI-NET/docs/5.1.1/web/albums"}},n=[{value:"First steps",id:"first-steps",children:[{value:"Imports",id:"imports",children:[]},{value:"Basic-Usage",id:"basic-usage",children:[]}]},{value:"Error-Handling",id:"error-handling",children:[]},{value:"Sync vs Asynchronous",id:"sync-vs-asynchronous",children:[]},{value:"API-Reference",id:"api-reference",children:[{value:"Albums",id:"albums",children:[]},{value:"Artists",id:"artists",children:[]},{value:"Browse",id:"browse",children:[]},{value:"Follow",id:"follow",children:[]},{value:"Library",id:"library",children:[]},{value:"Personalization",id:"personalization",children:[]},{value:"Player",id:"player",children:[]},{value:"Playlists",id:"playlists",children:[]},{value:"Profiles",id:"profiles",children:[]},{value:"Search",id:"search",children:[]},{value:"Tracks",id:"tracks",children:[]},{value:"Util",id:"util",children:[]}]}],c={toc:n};function o(e){var t=e.components,a=Object(l.a)(e,["components"]);return Object(i.b)("wrapper",Object(r.a)({},c,a,{components:t,mdxType:"MDXLayout"}),Object(i.b)("p",null,"This API provides full access to the new SpotifyWebAPI introduced ",Object(i.b)("a",{parentName:"p",href:"https://developer.spotify.com/web-api/"},"here"),".\nWith it, you can search for Tracks/Albums/Artists and also get User-based information.\nIt's also possible to create new playlists and add tracks to it."),Object(i.b)("h2",{id:"first-steps"},"First steps"),Object(i.b)("h3",{id:"imports"},"Imports"),Object(i.b)("p",null,"So after you added the API to your project, you may want to add following imports to your files:"),Object(i.b)("pre",null,Object(i.b)("code",{parentName:"pre",className:"language-csharp"},"using SpotifyAPI.Web; //Base Namespace\nusing SpotifyAPI.Web.Enums; //Enums\nusing SpotifyAPI.Web.Models; //Models for the JSON-responses\n")),Object(i.b)("h3",{id:"basic-usage"},"Basic-Usage"),Object(i.b)("p",null,"Now you can actually start doing calls to the SpotifyAPI, just create a new Instance of SpotifyWebAPI:"),Object(i.b)("pre",null,Object(i.b)("code",{parentName:"pre",className:"language-csharp"},'private static SpotifyWebAPI _spotify;\n\npublic static void Main(String[] args)\n{\n _spotify = new SpotifyWebAPI()\n {\n AccessToken = "XXXXXXXXXXXX",\n TokenType = "Bearer"\n }\n FullTrack track = _spotify.GetTrack("3Hvu1pq89D4R0lyPBoujSv");\n Console.WriteLine(track.Name); //Yeay! We just printed a tracks name.\n}\n')),Object(i.b)("p",null,"You may note that we used ",Object(i.b)("inlineCode",{parentName:"p"},"AccessToken")," and ",Object(i.b)("inlineCode",{parentName:"p"},"TokenType"),". Spotify does not allow un-authorized access to their API. You will need to implement one of the auth flows. Luckily, ",Object(i.b)("inlineCode",{parentName:"p"},"SpotifyAPI.Web.Auth")," exists for this reason. A simple way to receive a ",Object(i.b)("inlineCode",{parentName:"p"},"AccessToken")," is via ",Object(i.b)("inlineCode",{parentName:"p"},"CredentialAuth"),":"),Object(i.b)("pre",null,Object(i.b)("code",{parentName:"pre",className:"language-csharp"},'CredentialsAuth auth = new CredentialsAuth("YourClientID", "YourClientSecret");\nToken token = await auth.GetToken();\n_spotify = new SpotifyWebAPI()\n{\n AccessToken = token.AccessToken,\n TokenType = token.TokenType\n}\n')),Object(i.b)("p",null,"For more info, visit the ",Object(i.b)("a",{parentName:"p",href:"/SpotifyAPI-NET/docs/5.1.1/auth/getting_started"},"Getting Started of SpotifyAPI.Web.Auth")),Object(i.b)("h2",{id:"error-handling"},"Error-Handling"),Object(i.b)("p",null,"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:"),Object(i.b)("pre",null,Object(i.b)("code",{parentName:"pre",className:"language-csharp"},'PrivateProfile profile = _spotify.GetPrivateProfile();\nif (profile.HasError())\n{\n Console.WriteLine("Error Status: " + profile.Error.Status);\n Console.WriteLine("Error Msg: " + profile.Error.Message);\n}\n')),Object(i.b)("p",null,"In case some or all of the returned values are null, consult error status and message, they can lead to an explanation!"),Object(i.b)("h2",{id:"sync-vs-asynchronous"},"Sync vs Asynchronous"),Object(i.b)("p",null,"Every API-Call has an ",Object(i.b)("inlineCode",{parentName:"p"},"asynchronous")," and ",Object(i.b)("inlineCode",{parentName:"p"},"synchronous")," method."),Object(i.b)("pre",null,Object(i.b)("code",{parentName:"pre",className:"language-csharp"},"public async void Test()\n{\n var asyncProfile = await _spotify.GetPrivateProfileAsync();\n var syncProfile = _spotify.GetPrivateProfile();\n}\n")),Object(i.b)("p",null,"Note that the ",Object(i.b)("inlineCode",{parentName:"p"},"synchronous")," call will block the current Thread!"),Object(i.b)("h2",{id:"api-reference"},"API-Reference"),Object(i.b)("h3",{id:"albums"},"Albums"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/albums#getalbumtracks"},"GetAlbumTracks")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/albums#getalbum"},"GetAlbum")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/albums#getseveralalbums"},"GetSeveralAlbums"))),Object(i.b)("h3",{id:"artists"},"Artists"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/artists#getartist"},"GetArtist")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/artists#getrelatedartists"},"GetRelatedArtists")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/artists#getartiststoptracks"},"GetArtistsTopTracks")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/artists#getartistsalbums"},"GetArtistsAlbums")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/artists#getseveralartists"},"GetSeveralArtists"))),Object(i.b)("h3",{id:"browse"},"Browse"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/browse#getfeaturedplaylists"},"GetFeaturedPlaylists")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/browse#getnewalbumreleases"},"GetNewAlbumReleases")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/browse#getcategories"},"GetCategories")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/browse#getcategory"},"GetCategory")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/browse#getcategoryplaylists"},"GetCategoryPlaylists"))),Object(i.b)("h3",{id:"follow"},"Follow"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/follow#follow"},"Follow")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/follow#unfollow"},"Unfollow")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/follow#isfollowing"},"IsFollowing")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/follow#followplaylist"},"FollowPlaylist")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/follow#unfollowplaylist"},"UnfollowPlaylist")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/follow#isfollowingplaylist"},"IsFollowingPlaylist"))),Object(i.b)("h3",{id:"library"},"Library"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/library#savetracks"},"SaveTracks")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/library#savetrack"},"SaveTrack")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/library#getsavedtracks"},"GetSavedTracks")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/library#removesavedtracks"},"RemoveSavedTracks")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/library#checksavedtracks"},"CheckSavedTracks")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/library#savealbums"},"SaveAlbums")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/library#savealbum"},"SaveAlbum")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/library#getsavedalbums"},"GetSavedAlbums")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/library#removesavedalbums"},"RemoveSavedAlbums")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/library#checksavedalbums"},"CheckSavedAlbums"))),Object(i.b)("h3",{id:"personalization"},"Personalization"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/personalization#getuserstoptracks"},"GetUsersTopTracks")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/personalization#getuserstopartists"},"GetUsersTopArtists")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/personalization#getusersrecentlyplayedtracks"},"GetUsersRecentlyPlayedTracks"))),Object(i.b)("h3",{id:"player"},"Player"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/player#getdevices"},"GetDevices")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/player#getplayback"},"GetPlayback")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/player#getplayingtrack"},"GetPlayingTrack")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/player#transferplayback"},"TransferPlayback")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/player#resumeplayback"},"ResumePlayback")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/player#pauseplayback"},"PausePlayback")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/player#skipplaybacktonext"},"SkipPlaybackToNext")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/player#skipplaybacktoprevious"},"SkipPlaybackToPrevious")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/player#setrepeatmode"},"SetRepeatMode")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/player#setvolume"},"SetVolume")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/player#setshuffle"},"SetShuffle"))),Object(i.b)("h3",{id:"playlists"},"Playlists"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/playlists#getuserplaylists"},"GetUserPlaylists")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/playlists#getplaylist"},"GetPlaylist")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/playlists#getplaylisttracks"},"GetPlaylistTracks")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/playlists#createplaylist"},"CreatePlaylist")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/playlists#updateplaylist"},"UpdatePlaylist")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/playlists#replaceplaylisttracks"},"ReplacePlaylistTracks")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/playlists#removeplaylisttracks"},"RemovePlaylistTracks")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/playlists#removeplaylisttrack"},"RemovePlaylistTrack")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/playlists#addplaylisttracks"},"AddPlaylistTracks")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/playlists#addplaylisttrack"},"AddPlaylistTrack")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/playlists#reorderplaylist"},"ReorderPlaylist"))),Object(i.b)("h3",{id:"profiles"},"Profiles"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/profiles#getpublicprofile"},"GetPublicProfile")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/profiles#getprivateprofile"},"GetPrivateProfile"))),Object(i.b)("h3",{id:"search"},"Search"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/search#searchitems"},"SearchItems")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/search#searchitemsescaped"},"SearchItemsEscaped"))),Object(i.b)("h3",{id:"tracks"},"Tracks"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/tracks#getseveraltracks"},"GetSeveralTracks")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/tracks#gettrack"},"GetTrack")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/tracks#getaudioanalysis"},"GetAudioAnalysis"))),Object(i.b)("h3",{id:"util"},"Util"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",{parentName:"li",href:"/SpotifyAPI-NET/docs/5.1.1/web/utilities"},"Utility-Functions"))))}o.isMDXComponent=!0}}]);