Git Product home page Git Product logo

spotify-api-go-sdk's Introduction

Go API client for openapi

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 <a href="https://developer.spotify.com/documentation/general/guides/authorization-guide/\">OAuth 2.0.

The base URI for all Web API requests is https://api.spotify.com/v1.

Need help? See our <a href="https://developer.spotify.com/documentation/web-api/guides/\">Web API guides for more information, or visit the <a href="https://community.spotify.com/t5/Spotify-for-Developers/bd-p/Spotify_Developer\">Spotify for Developers community forum to ask questions and connect with other developers.

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import openapi "github.com/viqueen/spotify-api-go-sdk"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value openapi.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value openapi.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using openapi.ContextOperationServerIndices and openapi.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to https://api.spotify.com/v1

Class Method HTTP request Description
AlbumsAPI CheckUsersSavedAlbums Get /me/albums/contains Check User's Saved Albums
AlbumsAPI GetAnAlbum Get /albums/{id} Get Album
AlbumsAPI GetAnAlbumsTracks Get /albums/{id}/tracks Get Album Tracks
AlbumsAPI GetAnArtistsAlbums Get /artists/{id}/albums Get Artist's Albums
AlbumsAPI GetMultipleAlbums Get /albums Get Several Albums
AlbumsAPI GetNewReleases Get /browse/new-releases Get New Releases
AlbumsAPI GetUsersSavedAlbums Get /me/albums Get User's Saved Albums
AlbumsAPI RemoveAlbumsUser Delete /me/albums Remove Users' Saved Albums
AlbumsAPI SaveAlbumsUser Put /me/albums Save Albums for Current User
ArtistsAPI CheckCurrentUserFollows Get /me/following/contains Check If User Follows Artists or Users
ArtistsAPI FollowArtistsUsers Put /me/following Follow Artists or Users
ArtistsAPI GetAnArtist Get /artists/{id} Get Artist
ArtistsAPI GetAnArtistsAlbums Get /artists/{id}/albums Get Artist's Albums
ArtistsAPI GetAnArtistsRelatedArtists Get /artists/{id}/related-artists Get Artist's Related Artists
ArtistsAPI GetAnArtistsTopTracks Get /artists/{id}/top-tracks Get Artist's Top Tracks
ArtistsAPI GetFollowed Get /me/following Get Followed Artists
ArtistsAPI GetMultipleArtists Get /artists Get Several Artists
ArtistsAPI UnfollowArtistsUsers Delete /me/following Unfollow Artists or Users
AudiobooksAPI CheckUsersSavedAudiobooks Get /me/audiobooks/contains Check User's Saved Audiobooks
AudiobooksAPI GetAnAudiobook Get /audiobooks/{id} Get an Audiobook
AudiobooksAPI GetAudiobookChapters Get /audiobooks/{id}/chapters Get Audiobook Chapters
AudiobooksAPI GetMultipleAudiobooks Get /audiobooks Get Several Audiobooks
AudiobooksAPI GetUsersSavedAudiobooks Get /me/audiobooks Get User's Saved Audiobooks
AudiobooksAPI RemoveAudiobooksUser Delete /me/audiobooks Remove User's Saved Audiobooks
AudiobooksAPI SaveAudiobooksUser Put /me/audiobooks Save Audiobooks for Current User
CategoriesAPI GetACategoriesPlaylists Get /browse/categories/{category_id}/playlists Get Category's Playlists
CategoriesAPI GetACategory Get /browse/categories/{category_id} Get Single Browse Category
CategoriesAPI GetCategories Get /browse/categories Get Several Browse Categories
ChaptersAPI GetAChapter Get /chapters/{id} Get a Chapter
ChaptersAPI GetAudiobookChapters Get /audiobooks/{id}/chapters Get Audiobook Chapters
ChaptersAPI GetSeveralChapters Get /chapters Get Several Chapters
EpisodesAPI CheckUsersSavedEpisodes Get /me/episodes/contains Check User's Saved Episodes
EpisodesAPI GetAShowsEpisodes Get /shows/{id}/episodes Get Show Episodes
EpisodesAPI GetAnEpisode Get /episodes/{id} Get Episode
EpisodesAPI GetMultipleEpisodes Get /episodes Get Several Episodes
EpisodesAPI GetUsersSavedEpisodes Get /me/episodes Get User's Saved Episodes
EpisodesAPI RemoveEpisodesUser Delete /me/episodes Remove User's Saved Episodes
EpisodesAPI SaveEpisodesUser Put /me/episodes Save Episodes for Current User
GenresAPI GetRecommendationGenres Get /recommendations/available-genre-seeds Get Available Genre Seeds
LibraryAPI ChangePlaylistDetails Put /playlists/{playlist_id} Change Playlist Details
LibraryAPI CheckCurrentUserFollows Get /me/following/contains Check If User Follows Artists or Users
LibraryAPI CheckUsersSavedAlbums Get /me/albums/contains Check User's Saved Albums
LibraryAPI CheckUsersSavedAudiobooks Get /me/audiobooks/contains Check User's Saved Audiobooks
LibraryAPI CheckUsersSavedEpisodes Get /me/episodes/contains Check User's Saved Episodes
LibraryAPI CheckUsersSavedShows Get /me/shows/contains Check User's Saved Shows
LibraryAPI CheckUsersSavedTracks Get /me/tracks/contains Check User's Saved Tracks
LibraryAPI CreatePlaylist Post /users/{user_id}/playlists Create Playlist
LibraryAPI FollowArtistsUsers Put /me/following Follow Artists or Users
LibraryAPI GetAListOfCurrentUsersPlaylists Get /me/playlists Get Current User's Playlists
LibraryAPI GetFollowed Get /me/following Get Followed Artists
LibraryAPI GetUsersSavedAlbums Get /me/albums Get User's Saved Albums
LibraryAPI GetUsersSavedAudiobooks Get /me/audiobooks Get User's Saved Audiobooks
LibraryAPI GetUsersSavedEpisodes Get /me/episodes Get User's Saved Episodes
LibraryAPI GetUsersSavedShows Get /me/shows Get User's Saved Shows
LibraryAPI GetUsersSavedTracks Get /me/tracks Get User's Saved Tracks
LibraryAPI GetUsersTopArtistsAndTracks Get /me/top/{type} Get User's Top Items
LibraryAPI RemoveAlbumsUser Delete /me/albums Remove Users' Saved Albums
LibraryAPI RemoveAudiobooksUser Delete /me/audiobooks Remove User's Saved Audiobooks
LibraryAPI RemoveEpisodesUser Delete /me/episodes Remove User's Saved Episodes
LibraryAPI RemoveShowsUser Delete /me/shows Remove User's Saved Shows
LibraryAPI RemoveTracksUser Delete /me/tracks Remove User's Saved Tracks
LibraryAPI SaveAlbumsUser Put /me/albums Save Albums for Current User
LibraryAPI SaveAudiobooksUser Put /me/audiobooks Save Audiobooks for Current User
LibraryAPI SaveEpisodesUser Put /me/episodes Save Episodes for Current User
LibraryAPI SaveShowsUser Put /me/shows Save Shows for Current User
LibraryAPI SaveTracksUser Put /me/tracks Save Tracks for Current User
LibraryAPI UnfollowArtistsUsers Delete /me/following Unfollow Artists or Users
MarketsAPI GetAvailableMarkets Get /markets Get Available Markets
PlayerAPI AddToQueue Post /me/player/queue Add Item to Playback Queue
PlayerAPI GetAUsersAvailableDevices Get /me/player/devices Get Available Devices
PlayerAPI GetInformationAboutTheUsersCurrentPlayback Get /me/player Get Playback State
PlayerAPI GetQueue Get /me/player/queue Get the User's Queue
PlayerAPI GetRecentlyPlayed Get /me/player/recently-played Get Recently Played Tracks
PlayerAPI GetTheUsersCurrentlyPlayingTrack Get /me/player/currently-playing Get Currently Playing Track
PlayerAPI PauseAUsersPlayback Put /me/player/pause Pause Playback
PlayerAPI SeekToPositionInCurrentlyPlayingTrack Put /me/player/seek Seek To Position
PlayerAPI SetRepeatModeOnUsersPlayback Put /me/player/repeat Set Repeat Mode
PlayerAPI SetVolumeForUsersPlayback Put /me/player/volume Set Playback Volume
PlayerAPI SkipUsersPlaybackToNextTrack Post /me/player/next Skip To Next
PlayerAPI SkipUsersPlaybackToPreviousTrack Post /me/player/previous Skip To Previous
PlayerAPI StartAUsersPlayback Put /me/player/play Start/Resume Playback
PlayerAPI ToggleShuffleForUsersPlayback Put /me/player/shuffle Toggle Playback Shuffle
PlayerAPI TransferAUsersPlayback Put /me/player Transfer Playback
PlaylistsAPI AddTracksToPlaylist Post /playlists/{playlist_id}/tracks Add Items to Playlist
PlaylistsAPI ChangePlaylistDetails Put /playlists/{playlist_id} Change Playlist Details
PlaylistsAPI CheckIfUserFollowsPlaylist Get /playlists/{playlist_id}/followers/contains Check if Users Follow Playlist
PlaylistsAPI CreatePlaylist Post /users/{user_id}/playlists Create Playlist
PlaylistsAPI FollowPlaylist Put /playlists/{playlist_id}/followers Follow Playlist
PlaylistsAPI GetACategoriesPlaylists Get /browse/categories/{category_id}/playlists Get Category's Playlists
PlaylistsAPI GetAListOfCurrentUsersPlaylists Get /me/playlists Get Current User's Playlists
PlaylistsAPI GetFeaturedPlaylists Get /browse/featured-playlists Get Featured Playlists
PlaylistsAPI GetListUsersPlaylists Get /users/{user_id}/playlists Get User's Playlists
PlaylistsAPI GetPlaylist Get /playlists/{playlist_id} Get Playlist
PlaylistsAPI GetPlaylistCover Get /playlists/{playlist_id}/images Get Playlist Cover Image
PlaylistsAPI GetPlaylistsTracks Get /playlists/{playlist_id}/tracks Get Playlist Items
PlaylistsAPI RemoveTracksPlaylist Delete /playlists/{playlist_id}/tracks Remove Playlist Items
PlaylistsAPI ReorderOrReplacePlaylistsTracks Put /playlists/{playlist_id}/tracks Update Playlist Items
PlaylistsAPI UnfollowPlaylist Delete /playlists/{playlist_id}/followers Unfollow Playlist
PlaylistsAPI UploadCustomPlaylistCover Put /playlists/{playlist_id}/images Add Custom Playlist Cover Image
SearchAPI Search Get /search Search for Item
ShowsAPI CheckUsersSavedShows Get /me/shows/contains Check User's Saved Shows
ShowsAPI GetAShow Get /shows/{id} Get Show
ShowsAPI GetAShowsEpisodes Get /shows/{id}/episodes Get Show Episodes
ShowsAPI GetMultipleShows Get /shows Get Several Shows
ShowsAPI GetUsersSavedShows Get /me/shows Get User's Saved Shows
ShowsAPI RemoveShowsUser Delete /me/shows Remove User's Saved Shows
ShowsAPI SaveShowsUser Put /me/shows Save Shows for Current User
TracksAPI AddTracksToPlaylist Post /playlists/{playlist_id}/tracks Add Items to Playlist
TracksAPI CheckUsersSavedTracks Get /me/tracks/contains Check User's Saved Tracks
TracksAPI GetAnAlbumsTracks Get /albums/{id}/tracks Get Album Tracks
TracksAPI GetAnArtistsTopTracks Get /artists/{id}/top-tracks Get Artist's Top Tracks
TracksAPI GetAudioAnalysis Get /audio-analysis/{id} Get Track's Audio Analysis
TracksAPI GetAudioFeatures Get /audio-features/{id} Get Track's Audio Features
TracksAPI GetPlaylistsTracks Get /playlists/{playlist_id}/tracks Get Playlist Items
TracksAPI GetRecommendations Get /recommendations Get Recommendations
TracksAPI GetSeveralAudioFeatures Get /audio-features Get Several Tracks' Audio Features
TracksAPI GetSeveralTracks Get /tracks Get Several Tracks
TracksAPI GetTrack Get /tracks/{id} Get Track
TracksAPI GetUsersSavedTracks Get /me/tracks Get User's Saved Tracks
TracksAPI GetUsersTopArtistsAndTracks Get /me/top/{type} Get User's Top Items
TracksAPI RemoveTracksPlaylist Delete /playlists/{playlist_id}/tracks Remove Playlist Items
TracksAPI RemoveTracksUser Delete /me/tracks Remove User's Saved Tracks
TracksAPI ReorderOrReplacePlaylistsTracks Put /playlists/{playlist_id}/tracks Update Playlist Items
TracksAPI SaveTracksUser Put /me/tracks Save Tracks for Current User
UsersAPI CheckCurrentUserFollows Get /me/following/contains Check If User Follows Artists or Users
UsersAPI CheckIfUserFollowsPlaylist Get /playlists/{playlist_id}/followers/contains Check if Users Follow Playlist
UsersAPI FollowArtistsUsers Put /me/following Follow Artists or Users
UsersAPI FollowPlaylist Put /playlists/{playlist_id}/followers Follow Playlist
UsersAPI GetCurrentUsersProfile Get /me Get Current User's Profile
UsersAPI GetFollowed Get /me/following Get Followed Artists
UsersAPI GetListUsersPlaylists Get /users/{user_id}/playlists Get User's Playlists
UsersAPI GetUsersProfile Get /users/{user_id} Get User's Profile
UsersAPI GetUsersTopArtistsAndTracks Get /me/top/{type} Get User's Top Items
UsersAPI UnfollowArtistsUsers Delete /me/following Unfollow Artists or Users
UsersAPI UnfollowPlaylist Delete /playlists/{playlist_id}/followers Unfollow Playlist

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

oauth_2_0

  • Type: OAuth
  • Flow: accessCode
  • Authorization URL: https://accounts.spotify.com/authorize
  • Scopes:
  • 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.

Example

auth := context.WithValue(context.Background(), openapi.ContextAccessToken, "ACCESSTOKENSTRING")
r, err := client.Service.Operation(auth, args)

Or via OAuth2 module to automatically refresh tokens and perform user authentication.

import "golang.org/x/oauth2"

/* Perform OAuth2 round trip request and obtain a token */

tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
auth := context.WithValue(oauth2.NoContext, openapi.ContextOAuth2, tokenSource)
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author

spotify-api-go-sdk's People

Contributors

viqueen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.