"use strict";(self.webpackChunkspotify_api_docs=self.webpackChunkspotify_api_docs||[]).push([[6347],{3905:function(e,t,r){r.d(t,{Zo:function(){return c},kt:function(){return f}});var a=r(7294);function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function l(e){for(var t=1;t=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}var u=a.createContext({}),s=function(e){var t=a.useContext(u),r=t;return e&&(r="function"==typeof e?e(t):l(l({},t),e)),r},c=function(e){var t=s(e.components);return a.createElement(u.Provider,{value:t},e.children)},p={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},d=a.forwardRef((function(e,t){var r=e.components,n=e.mdxType,o=e.originalType,u=e.parentName,c=i(e,["components","mdxType","originalType","parentName"]),d=s(r),f=n,m=d["".concat(u,".").concat(f)]||d[f]||p[f]||o;return r?a.createElement(m,l(l({ref:t},c),{},{components:r})):a.createElement(m,l({ref:t},c))}));function f(e,t){var r=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var o=r.length,l=new Array(o);l[0]=d;var i={};for(var u in t)hasOwnProperty.call(t,u)&&(i[u]=t[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,l[1]=i;for(var s=2;s child <"+("string"==typeof e.type?e.type:e.type.name)+'>: all children of the component should be , and every should have a unique "value" prop.')})))?void 0:r.filter(Boolean))?t:[]}(e).map((function(e){var t=e.props;return{value:t.value,label:t.label,attributes:t.attributes,default:t.default}}))}function y(e){var t=e.values,r=e.children;return(0,n.useMemo)((function(){var e=null!=t?t:m(r);return function(e){var t=(0,d.l)(e,(function(e,t){return e.value===t.value}));if(t.length>0)throw new Error('Docusaurus error: Duplicate values "'+t.map((function(e){return e.value})).join(", ")+'" found in . Every value needs to be unique.')}(e),e}),[t,r])}function h(e){var t=e.value;return e.tabValues.some((function(e){return e.value===t}))}function b(e){var t=e.queryString,r=void 0!==t&&t,a=e.groupId,o=(0,c.k6)(),l=function(e){var t=e.queryString,r=void 0!==t&&t,a=e.groupId;if("string"==typeof r)return r;if(!1===r)return null;if(!0===r&&!a)throw new Error('Docusaurus error: The component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return null!=a?a:null}({queryString:r,groupId:a});return[(0,p._X)(l),(0,n.useCallback)((function(e){if(l){var t=new URLSearchParams(o.location.search);t.set(l,e),o.replace(Object.assign({},o.location,{search:t.toString()}))}}),[l,o])]}function g(e){var t,r,a,o,l=e.defaultValue,i=e.queryString,u=void 0!==i&&i,s=e.groupId,c=y(e),p=(0,n.useState)((function(){return function(e){var t,r=e.defaultValue,a=e.tabValues;if(0===a.length)throw new Error("Docusaurus error: the component requires at least one children component");if(r){if(!h({value:r,tabValues:a}))throw new Error('Docusaurus error: The has a defaultValue "'+r+'" but none of its children has the corresponding value. Available values are: '+a.map((function(e){return e.value})).join(", ")+". If you intend to show no default tab, use defaultValue={null} instead.");return r}var n=null!=(t=a.find((function(e){return e.default})))?t:a[0];if(!n)throw new Error("Unexpected error: 0 tabValues");return n.value}({defaultValue:l,tabValues:c})})),d=p[0],m=p[1],g=b({queryString:u,groupId:s}),v=g[0],k=g[1],I=(t=function(e){return e?"docusaurus.tab."+e:null}({groupId:s}.groupId),r=(0,f.Nk)(t),a=r[0],o=r[1],[a,(0,n.useCallback)((function(e){t&&o.set(e)}),[t,o])]),P=I[0],A=I[1],N=function(){var e=null!=v?v:P;return h({value:e,tabValues:c})?e:null}();return(0,n.useLayoutEffect)((function(){N&&m(N)}),[N]),{selectedValue:d,selectValue:(0,n.useCallback)((function(e){if(!h({value:e,tabValues:c}))throw new Error("Can't select invalid tab value="+e);m(e),k(e),A(e)}),[k,A,c]),tabValues:c}}var v=r(2389),k="tabList__CuJ",I="tabItem_LNqP";function P(e){var t=e.className,r=e.block,a=e.selectedValue,l=e.selectValue,i=e.tabValues,c=[],p=(0,s.o5)().blockElementScrollPositionUntilNextRender,d=function(e){var t=e.currentTarget,r=c.indexOf(t),n=i[r].value;n!==a&&(p(t),l(n))},f=function(e){var t,r=null;switch(e.key){case"Enter":d(e);break;case"ArrowRight":var a,n=c.indexOf(e.currentTarget)+1;r=null!=(a=c[n])?a:c[0];break;case"ArrowLeft":var o,l=c.indexOf(e.currentTarget)-1;r=null!=(o=c[l])?o:c[c.length-1]}null==(t=r)||t.focus()};return n.createElement("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,o.Z)("tabs",{"tabs--block":r},t)},i.map((function(e){var t=e.value,r=e.label,l=e.attributes;return n.createElement("li",(0,u.Z)({role:"tab",tabIndex:a===t?0:-1,"aria-selected":a===t,key:t,ref:function(e){return c.push(e)},onKeyDown:f,onClick:d},l,{className:(0,o.Z)("tabs__item",I,null==l?void 0:l.className,{"tabs__item--active":a===t})}),null!=r?r:t)})))}function A(e){var t=e.lazy,r=e.children,a=e.selectedValue,o=(Array.isArray(r)?r:[r]).filter(Boolean);if(t){var l=o.find((function(e){return e.props.value===a}));return l?(0,n.cloneElement)(l,{className:"margin-top--md"}):null}return n.createElement("div",{className:"margin-top--md"},o.map((function(e,t){return(0,n.cloneElement)(e,{key:t,hidden:e.props.value!==a})})))}function N(e){var t=g(e);return n.createElement("div",{className:(0,o.Z)("tabs-container",k)},n.createElement(P,(0,u.Z)({},e,t)),n.createElement(A,(0,u.Z)({},e,t)))}function S(e){var t=(0,v.Z)();return n.createElement(N,(0,u.Z)({key:String(t)},e))}var T=function(){return n.createElement("div",{style:{padding:"10px"}},n.createElement(S,{defaultValue:"cli",values:[{label:".NET CLI",value:"cli"},{label:"Package Manager",value:"nuget"},{label:"Package Reference",value:"reference"}]},n.createElement(i,{value:"cli"},n.createElement(a.Z,{language:"shell",className:"shell"},"dotnet add package SpotifyAPI.Web\n# Optional Auth module, which includes an embedded HTTP Server for OAuth2\ndotnet add package SpotifyAPI.Web.Auth\n")),n.createElement(i,{value:"nuget"},n.createElement(a.Z,{language:"shell",className:"shell"},"Install-Package SpotifyAPI.Web\n# Optional Auth module, which includes an embedded HTTP Server for OAuth2\nInstall-Package SpotifyAPI.Web.Auth\n")),n.createElement(i,{value:"reference"},n.createElement(a.Z,{language:"xml",className:"xml"},'\n\x3c!-- Optional Auth module, which includes an embedded HTTP Server for OAuth2 --\x3e\n\n'))))}},8230:function(e,t,r){r.r(t),r.d(t,{assets:function(){return p},contentTitle:function(){return s},default:function(){return m},frontMatter:function(){return u},metadata:function(){return c},toc:function(){return d}});var a=r(7462),n=r(3366),o=(r(7294),r(3905)),l=r(4415),i=["components"],u={id:"getting_started",title:"Getting Started"},s=void 0,c={unversionedId:"getting_started",id:"getting_started",title:"Getting Started",description:"Adding SpotifyAPI-NET to your project",source:"@site/docs/getting_started.md",sourceDirName:".",slug:"/getting_started",permalink:"/SpotifyAPI-NET/docs/getting_started",draft:!1,editUrl:"https://github.com/JohnnyCrazy/SpotifyAPI-NET/edit/master/SpotifyAPI.Docs/docs/getting_started.md",tags:[],version:"current",lastUpdatedBy:"Jonas Dellinger",lastUpdatedAt:1685219501,formattedLastUpdatedAt:"May 27, 2023",frontMatter:{id:"getting_started",title:"Getting Started"},sidebar:"docs",previous:{title:"Introduction",permalink:"/SpotifyAPI-NET/docs/introduction"},next:{title:"Error Handling",permalink:"/SpotifyAPI-NET/docs/error_handling"}},p={},d=[{value:"Adding SpotifyAPI-NET to your project",id:"adding-spotifyapi-net-to-your-project",level:2},{value:"Package Managers",id:"package-managers",level:3},{value:"Add DLL Manually",id:"add-dll-manually",level:3},{value:"Compile Yourself",id:"compile-yourself",level:3},{value:"First API Calls",id:"first-api-calls",level:2},{value:"Query/Body Parameters",id:"querybody-parameters",level:2},{value:"Guides",id:"guides",level:2}],f={toc:d};function m(e){var t=e.components,r=(0,n.Z)(e,i);return(0,o.kt)("wrapper",(0,a.Z)({},f,r,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h2",{id:"adding-spotifyapi-net-to-your-project"},"Adding SpotifyAPI-NET to your project"),(0,o.kt)("p",null,"The library can be added to your project via the following methods:"),(0,o.kt)("h3",{id:"package-managers"},"Package Managers"),(0,o.kt)(l.Z,{mdxType:"InstallInstructions"}),(0,o.kt)("h3",{id:"add-dll-manually"},"Add DLL Manually"),(0,o.kt)("p",null,"You can also grab the latest compiled DLL from our ",(0,o.kt)("a",{parentName:"p",href:"https://github.com/johnnycrazy/spotifyapi-net/releases"},"GitHub Releases Page"),". It can be added to your project via Visual Studio or directly in your ",(0,o.kt)("inlineCode",{parentName:"p"},".csproj"),":"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-xml"},'\n \n ..\\Dlls\\SpotifyAPI.Web.dll\n \n\n')),(0,o.kt)("h3",{id:"compile-yourself"},"Compile Yourself"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-sh"},"git clone https://github.com/JohnnyCrazy/SpotifyAPI-NET.git\ncd SpotifyAPI-NET\ndotnet restore\ndotnet build\n\nls -la SpotifyAPI.Web/bin/Debug/netstandard2.1/SpotifyAPI.Web.dll\n")),(0,o.kt)("h2",{id:"first-api-calls"},"First API Calls"),(0,o.kt)("p",null,"You're now ready to issue your first calls to the Spotify API, a small console example:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-csharp"},'using System;\nusing System.Threading.Tasks;\nusing SpotifyAPI.Web;\n\nclass Program\n{\n static async Task Main()\n {\n var spotify = new SpotifyClient("YourAccessToken");\n\n var track = await spotify.Tracks.Get("1s6ux0lNiTziSrd7iUAADH");\n Console.WriteLine(track.Name);\n }\n}\n')),(0,o.kt)("admonition",{type:"tip"},(0,o.kt)("p",{parentName:"admonition"},"Notice that the spotify api does not allow unauthorized API access. Wondering where you should get an access token from? For a quick test, head over to the ",(0,o.kt)("a",{parentName:"p",href:"https://developer.spotify.com/console/get-album/"},"Spotify Developer Console")," and generate an access token with the required scopes! For a permanent solution, head over to the ",(0,o.kt)("a",{parentName:"p",href:"/SpotifyAPI-NET/docs/auth_introduction"},"authentication guides"),".")),(0,o.kt)("p",null,"There is no online documentation for every available API call, but XML inline docs are available:"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://github.com/JohnnyCrazy/SpotifyAPI-NET/blob/master/SpotifyAPI.Web/Clients/Interfaces/IUserProfileClient.cs"},"UserProfile")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://github.com/JohnnyCrazy/SpotifyAPI-NET/blob/master/SpotifyAPI.Web/Clients/Interfaces/IBrowseClient.cs"},"Browse")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://github.com/JohnnyCrazy/SpotifyAPI-NET/blob/master/SpotifyAPI.Web/Clients/Interfaces/IShowsClient.cs"},"Shows")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://github.com/JohnnyCrazy/SpotifyAPI-NET/blob/master/SpotifyAPI.Web/Clients/Interfaces/IPlaylistsClient.cs"},"Playlists")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://github.com/JohnnyCrazy/SpotifyAPI-NET/blob/master/SpotifyAPI.Web/Clients/Interfaces/ISearchClient.cs"},"Search")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://github.com/JohnnyCrazy/SpotifyAPI-NET/blob/master/SpotifyAPI.Web/Clients/Interfaces/IFollowClient.cs"},"Follow")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://github.com/JohnnyCrazy/SpotifyAPI-NET/blob/master/SpotifyAPI.Web/Clients/Interfaces/ITracksClient.cs"},"Tracks")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://github.com/JohnnyCrazy/SpotifyAPI-NET/blob/master/SpotifyAPI.Web/Clients/Interfaces/IPlayerClient.cs"},"Player")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://github.com/JohnnyCrazy/SpotifyAPI-NET/blob/master/SpotifyAPI.Web/Clients/Interfaces/IAlbumsClient.cs"},"Albums")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://github.com/JohnnyCrazy/SpotifyAPI-NET/blob/master/SpotifyAPI.Web/Clients/Interfaces/IArtistsClient.cs"},"Artists")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://github.com/JohnnyCrazy/SpotifyAPI-NET/blob/master/SpotifyAPI.Web/Clients/Interfaces/IPersonalizationClient.cs"},"Personalization")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://github.com/JohnnyCrazy/SpotifyAPI-NET/blob/master/SpotifyAPI.Web/Clients/Interfaces/IEpisodesClient.cs"},"Episodes")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://github.com/JohnnyCrazy/SpotifyAPI-NET/blob/master/SpotifyAPI.Web/Clients/Interfaces/ILibraryClient.cs"},"Library"))),(0,o.kt)("p",null,"All calls have the ",(0,o.kt)("a",{parentName:"p",href:"https://developer.spotify.com/documentation/web-api/reference-beta/"},"Spotify Web API documentation reference")," attached as a remark."),(0,o.kt)("h2",{id:"querybody-parameters"},"Query/Body Parameters"),(0,o.kt)("p",null,"If an API endpoint has query or body parameters, a request model can be supplied to the method"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-csharp"},'// No optional or required query/body parameters\n// The track ID is part of the request path --\x3e it\'s not treated as query/body parameter\nvar track = await spotify.Tracks.Get("1s6ux0lNiTziSrd7iUAADH");\n\n// Optional query/body parameter\nvar track = await spotify.Tracks.Get("1s6ux0lNiTziSrd7iUAADH", new TrackRequest{\n Market = "DE"\n});\n\n// Sometimes, query/body parameters are also required!\nvar tracks = await spotify.Tracks.GetSeveral(new TracksRequest(new List {\n "1s6ux0lNiTziSrd7iUAADH",\n "6YlOxoHWLjH6uVQvxUIUug"\n}));\n')),(0,o.kt)("p",null,"If a query/body parameter is required, it has to be supplied in the constructor of the request model. In the background, empty/null checks are also performed to make sure required parameters are not empty/null. If it is optional, it can be supplied as a property to the request model."),(0,o.kt)("h2",{id:"guides"},"Guides"),(0,o.kt)("p",null,'All other relevant topics are covered in the "Guides" and ',(0,o.kt)("a",{parentName:"p",href:"/SpotifyAPI-NET/docs/auth_introduction"},"Authentication Guides")," section in the sidebar!"))}m.isMDXComponent=!0}}]);