{"id":1910,"url":"https://github.com/Daltron/Spartan","last_synced_at":"2025-08-02T05:32:59.496Z","repository":{"id":56238803,"uuid":"79067954","full_name":"Daltron/Spartan","owner":"Daltron","description":"An Elegant Spotify Web API Library Written in Swift for iOS and macOS","archived":false,"fork":false,"pushed_at":"2020-10-30T01:31:26.000Z","size":1426,"stargazers_count":110,"open_issues_count":8,"forks_count":16,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-11-26T01:42:23.727Z","etag":null,"topics":["ios","macos","spotify","spotify-alternative","spotify-api","spotify-library","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Daltron.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["daltron"]}},"created_at":"2017-01-16T00:03:14.000Z","updated_at":"2024-05-29T20:57:25.000Z","dependencies_parsed_at":"2022-08-15T15:10:52.717Z","dependency_job_id":null,"html_url":"https://github.com/Daltron/Spartan","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daltron%2FSpartan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daltron%2FSpartan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daltron%2FSpartan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daltron%2FSpartan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Daltron","download_url":"https://codeload.github.com/Daltron/Spartan/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228443672,"owners_count":17920765,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","macos","spotify","spotify-alternative","spotify-api","spotify-library","swift"],"created_at":"2024-01-05T20:15:58.783Z","updated_at":"2024-12-06T09:30:31.732Z","avatar_url":"https://github.com/Daltron.png","language":"Swift","readme":"![Spartan](https://raw.githubusercontent.com/Daltron/Spartan/master/Spartan/Assets/spartan.png)\n\n[![CI Status](http://img.shields.io/travis/Daltron/Spartan.svg?style=flat)](https://travis-ci.org/Daltron/Spartan)\n[![Version](https://img.shields.io/cocoapods/v/Spartan.svg?style=flat)](http://cocoapods.org/pods/Spartan)\n\u003ca href=\"https://developer.apple.com/swift\"\u003e\u003cimg src=\"https://img.shields.io/badge/swift-4.2-4BC51D.svg?style=flat\" alt=\"Language: Swift\" /\u003e\u003c/a\u003e\n[![License](https://img.shields.io/cocoapods/l/Spartan.svg?style=flat)](http://cocoapods.org/pods/Spartan)\n[![Platform](https://img.shields.io/cocoapods/p/Spartan.svg?style=flat)](http://cocoapods.org/pods/Spartan)\n\n## Written in Swift 4.2\nSpartan is a lightweight, elegant, and easy to use Spotify Web API wrapper library for iOS and macOS written in Swift 3. Under the hood, Spartan makes request to the Spotify Web API. Those requests are then turned into clean, friendly, and easy to use objects.\n\n### What this library allows you to do:\n- ✅ Make any request that the Spotify Web API allows.\n\n### What this library doesn't do:\n- ❌ Authorization flows that help provide you with an authorization token. The [Spotify iOS SDK](https://github.com/spotify/ios-sdk) can help assist you with that.\n\n## Requirements\n\n - iOS 9.0+ / macOS 10.11+\n - xCode 9.0+\n\n## Installation\n\n### CocoaPods\n\nTo integrate Spartan into your xCode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '9.0'   # If you targeting iOS\nplatform :osx, '10.11' # If you targeting macOS\nuse_frameworks!\n\npod 'Spartan'\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\nThis will download any library dependencies you do not already have in your project.\n\n## Usage\n\n### Spartan Properties\n\n#### Authorization Token\n```swift\npublic static var authorizationToken: String?\n```\nThis is the token that is included with each request that requires OAuth authentication. If the request you make requires OAuth and this in nil, invalid, or expired, the request will fail. This can be left `nil` if you do not plan on making any requests that require OAuth authentication.\n\nEach time your token is refreshed, simply update it:\n\n```swift\nSpartan.authorizationToken = newToken\n```\n\n#### Logging\n```swift\npublic static var loggingEnabled: Bool = true\n```\n\nWhen enabled, before each request starts and after each request finishes, helpful statements will be printed to the console.\n\nA successful request will look something like this:\n\n```swift\n🔵 [SpartanRequestLogger] GET https://api.spotify.com/v1/me\n⚪️ [SpartanRequestLogger] GET https://api.spotify.com/v1/me (200 OK) 0.140969038009644 seconds\n```\n\nWhile a failed/invalid request will look something like this:\n\n```swift\n🔵 [SpartanRequestLogger] GET https://api.spotify.com/v1/me\n🔴 [SpartanRequestLogger] GET https://api.spotify.com/v1/me (401 Unauthorized) 0.81086003780365 seconds\n```\n\nThis can be enabled/disabled at any time anywhere in your code simply by:\n\n```swift\nSpartan.loggingEnabled = true/false\n```\n\n## Core\n\nFor more information on each request, please click the link associated with it. Spotify provides excellent documentation for each api request that they support. Spartan supports almost all query parameter fields that Spotify allows.\n\n### PagingObject\n\nQuite a few requests return a `PagingObject`. This is an offset based paging object that is a container for a set of objects. It contains a key called items whose value is an array of the requested objects. It can be used to get the previous set of items or the next set of items for a future call.\n\nFor example:\n\n```swift\n_ = Spartan.search(query: \"Five for Fighting\", type: .track, success: { (pagingObject: PagingObject\u003cTrack\u003e) in\n\tself.pagingObject = pagingObject\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\nThen later, if you need to load more data (scrolled to bottom of UITableView/UICollectionView, etc...) more data can be loaded/reloaded with these two methods:\n\n#### Get Next\n\n```swift\nif pagingObject.canMakeNextRequest {\n\n\tpagingObject.getNext(success: { (pagingObject) in\n   \t\t// Update the paging object\n   \t\tself.pagingObject = pagingObject            \n\t}, failure: { (error) in\n\t\tprint(error)\n\t})\n}\n```\n\n#### Get Previous\n\n```swift\nif pagingObject.canMakePreviousRequest {\n\n\tpagingObject.getPrevious(success: { (pagingObject) in\n   \t\t// Update the paging object\n   \t\tself.pagingObject = pagingObject            \n\t}, failure: { (error) in\n\t\tprint(error)\n\t})\n}\n```\n\n### Requests\n\n#### [Get an Album](https://developer.spotify.com/web-api/get-album/)\n\n```swift\n_ = Spartan.getAlbum(id: albumId, market: .us, success: { (album) in\n\t// Do something with the album    \n}, failure: { (error) in\n\tprint(error)      \n})\n```\n\n#### [Get Several Albums](https://developer.spotify.com/web-api/get-several-albums/)\n\n```swift\n_ = Spartan.getAlbums(ids: albumIds, market: .us, success: { (albums) in\n\t// Do something with the albums\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get an Album's Tracks](https://developer.spotify.com/web-api/get-albums-tracks/)\n\n```swift\n_ = Spartan.getTracks(albumId: albumId, limit: 20, offset: 0, market: .us, success: { (pagingObject) in\n\t// Get the tracks via pagingObject.items\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get an Artist](https://developer.spotify.com/web-api/get-artist/)\n\n```swift\n_ = Spartan.getArtist(id: artistId, success: { (artist) in\n\t// Do something with the artist\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get Several Artists](https://developer.spotify.com/web-api/get-several-artists/)\n\n```swift\n_ = Spartan.getArtists(ids: artistIds, success: { (artists) in\n\t// Do something with the artists\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get a Track](https://developer.spotify.com/web-api/search-item/)\n\n```swift\n_ = Spartan.getTrack(id: track, market: .us, success: { (track) in\n\t// Do something with the track\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get Several Tracks](https://developer.spotify.com/web-api/get-several-tracks/)\n\n```swift\n_ = Spartan.getTracks(ids: trackIds, market: .us, success: { (tracks) in\n\t// Do something with the tracks\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get an Artist's Albums](https://developer.spotify.com/web-api/get-artists-albums/)\n\n```swift\n_ = Spartan.getArtistAlbums(artistId: artistId, limit: 20, offset: 0, albumTypes: [.album, .single, .appearsOn, .compilation], market: .us, success: { (pagingObject) in\n\t// Get the albums via pagingObject.items\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get an Artist's Top Tracks](https://developer.spotify.com/web-api/get-artists-top-tracks/)\n\n```swift\n _ = Spartan.getArtistsTopTracks(artistId: artistId, country: .us, success: { (tracks) in\n\t// Do something with the tracks\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get an Artist's Related Artists](https://developer.spotify.com/web-api/get-artists-top-tracks/)\n\n```swift\n_ = Spartan.getArtistsRelatedArtists(artistId: artistId, success: { (artists) in\n\t// Do something with the artists\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Search for Albums](https://developer.spotify.com/web-api/search-item/)\n\n```swift\n_ = Spartan.search(query: query, type: .album, success: { (pagingObject: PagingObject\u003cSimplifiedAlbum\u003e) in\n\t// Get the albums via pagingObject.items     \n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Search for Artists](https://developer.spotify.com/web-api/search-item/)\n\n```swift\n_ = Spartan.search(query: query, type: .artist, success: { (pagingObject: PagingObject\u003cSimplifiedArtist\u003e) in\n\t// Get the artists via pagingObject.items     \n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Search for Playlists](https://developer.spotify.com/web-api/search-item/)\n\n```swift\n_ = Spartan.search(query: query, type: .playlist, success: { (pagingObject: PagingObject\u003cSimplifiedPlaylist\u003e) in\n\t// Get the playlists via pagingObject.items     \n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Search for Tracks](https://developer.spotify.com/web-api/search-item/)\n\n```swift\n_ = Spartan.search(query: query, type: .track, success: { (pagingObject: PagingObject\u003cSimplifiedTrack\u003e) in\n\t// Get the tracks via pagingObject.items     \n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get a User’s Profile](https://developer.spotify.com/web-api/get-users-profile/)\n\n```swift\n_ = Spartan.getUser(id: userId, success: { (user) in\n\t// Do something with the user\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get Audio Analysis for a Track](https://developer.spotify.com/web-api/get-audio-analysis/)\n\n```swift\n_ = Spartan.getAudioAnaylsis(trackId: trackId, success: { (audiAnalysis) in\n\t// Do something with the audio analysis\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get Audio Features for a Track](https://developer.spotify.com/web-api/get-audio-analysis/)\n\n```swift\n_ = Spartan.getAudioFeatures(trackId: trackId, success: { (audioFeaturesObject) in\n\t// Do something with the audio features object  \n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get Audio Features for a Track](https://developer.spotify.com/web-api/get-audio-features/)\n\n```swift\n_ = Spartan.getAudioFeatures(trackId: trackId, success: { (audioFeaturesObject) in\n\t// Do something with the audio features object  \n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get Audio Features for Several Tracks](https://developer.spotify.com/web-api/get-several-audio-features/)\n\n```swift\n_ = Spartan.getAudioFeatures(trackIds: trackIds, success: { (audioFeaturesObject) in\n\t// Do something with the audio features objects\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get a List of Featured Playlists](https://developer.spotify.com/web-api/get-list-featured-playlists/)\n\n```swift\n_ = Spartan.getFeaturedPlaylists(locale: locale, country: .us, timestamp: timestamp, limit: 20, offset: 0, success: { (featuredPlaylistsObject) in\n\t// Do something with the featured playlists object        \n}, failure: { (error) in\n\tprint(error)        \n})\n```\n\n#### [Get a List of New Releases](https://developer.spotify.com/web-api/get-list-new-releases/)\n\n```swift\n_ = Spartan.getNewReleases(country: .us, limit: 20, offset: 0, success: { (pagingObject) in\n\t// Get the albums via pagingObject.items\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get a List of Categories](https://developer.spotify.com/web-api/get-list-categories/)\n\n```swift\n_ = Spartan.getCategories(success: { (pagingObject) in\n\t// Get the categories via pagingObject.items\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get a Category’s Playlists](https://developer.spotify.com/web-api/get-categorys-playlists/)\n\n```swift\n_ = Spartan.getCategorysPlaylists(categoryId: categoryId, locale: locale, country: .us, limit: 20, offset: 0, success: { (pagingObject) in\n\t// Get the playlists via pagingObject.items\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get Current User’s Profile](https://developer.spotify.com/web-api/get-current-users-profile/)\n\n```swift\n_ = Spartan.getMe(success: { (user) in\n\t// Do something with the user object\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get User’s Followed Artists](https://developer.spotify.com/web-api/get-followed-artists/)\n\n```swift\n_ = Spartan.getMyFollowedArtists(success: { (pagingObject) in\n\t// Get artists via pagingObject.items\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Follow Artists](https://developer.spotify.com/web-api/follow-artists-users/)\n\n```swift\n_ = Spartan.follow(ids: artistIds, type: .artist, success: {\n\t// Artists are now followed   \n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Follow Users](https://developer.spotify.com/web-api/follow-artists-users/)\n\n```swift\n_ = Spartan.follow(ids: userIds, type: .user, success: {\n\t// Users are now followed   \n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Unfollow Artists](https://developer.spotify.com/web-api/unfollow-artists-users/)\n\n```swift\n_ = Spartan.unfollow(ids: artistIds, type: .artist, success: {\n\t// Artists are now unfollowed   \n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Unfollow Users](https://developer.spotify.com/web-api/unfollow-artists-users/)\n\n```swift\n_ = Spartan.unfollow(ids: userIds, type: .user, success: {\n\t// Users are now unfollowed   \n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Check if Current User Follows Artists](https://developer.spotify.com/web-api/check-current-user-follows/)\n\n```swift\n_ = Spartan.getIsFollowing(ids: artistIds, type: .artist, success: { (followingBools) in\n\t// Do something with the followingBools\n}, failure: { (error) in\n\tprint(error)        \n})\n```\n\n#### [Check if Current User Follows Users](https://developer.spotify.com/web-api/check-current-user-follows/)\n\n```swift\n_ = Spartan.getIsFollowing(ids: userIds, type: .user, success: { (followingBools) in\n\t// Do something with the followingBools\n}, failure: { (error) in\n\tprint(error)        \n})\n```\n\n#### [Follow a Playlist](https://developer.spotify.com/web-api/follow-playlist/)\n\n```swift\n_ = Spartan.followPlaylist(ownerId: ownerId, playlistId: playlistId, isPublic: true, success: {\n   // Playlist is now followed\n}, failure: { (error) in\n\tprint(error)           \n})\n```\n\n#### [Unfollow a Playlist](https://developer.spotify.com/web-api/unfollow-playlist/)\n\n```swift\n_ = Spartan.unfollowPlaylist(ownerId: ownerId, playlistId: playlistId, success: {\n\t// Playlist is now unfollowed     \n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get a User’s Saved Tracks](https://developer.spotify.com/web-api/save-tracks-user/)\n\n```swift\n _ = Spartan.getSavedTracks(limit: 20, offset: 0, market: .us, success: { (pagingObject) in\n\t// Get the saved tracks via pagingObject.items     \n}, failure: { (error) in\n\tprint(error)   \n})\n```\n\n#### [Save Tracks for User](https://developer.spotify.com/web-api/save-tracks-user/)\n\n```swift\n_ = Spartan.saveTracks(trackIds: trackIds, success: {\n\t// Tracks are now saved    \n}, failure: { (error) in\n\tprint(error)    \n})\n```\n\n#### [Remove User’s Saved Tracks](https://developer.spotify.com/web-api/remove-tracks-user/)\n\n```swift\n_ = Spartan.removeSavedTracks(trackIds: trackIds, success: {\n\t// Tracks are now removed\n}, failure: { (error) in\n    print(error)\n})\n```\n\n#### [Check User’s Saved Tracks](https://developer.spotify.com/web-api/check-users-saved-tracks/)\n\n```swift\n_ = Spartan.tracksAreSaved(trackIds: trackIds, success: { (savedBools) in\n    // Do something with the savedBools    \n}, failure: { (error) in\n    print(error)    \n})\n```\n\n#### [Get Current User’s Saved Albums](https://developer.spotify.com/web-api/get-users-saved-albums/)\n\n```swift\n _ = Spartan.getSavedAlbums(limit: 20, offset: 0, market: .us, success: { (pagingObject) in\n    // Get the saved albums via pagingObject.items    \n}, failure: { (error) in\n \tprint(error)      \n})        \n```\n\n#### [Save Albums for User](https://developer.spotify.com/web-api/save-albums-user/)\n\n```swift\n_ = Spartan.saveAlbums(albumIds: albumIds, success: {\n\t// Albums are now saved    \n}, failure: { (error) in\n\tprint(error)    \n})\n```\n\n#### [Remove User’s Saved Albums](https://developer.spotify.com/web-api/remove-albums-user/)\n\n```swift\n_ = Spartan.removeSavedAlbums(albumIds: albumIds, success: {\n\t// Albums are now removed\n}, failure: { (error) in\n    print(error)\n})\n```\n\n#### [Check User’s Saved Albums](https://developer.spotify.com/web-api/check-users-saved-albums/)\n\n```swift\n_ = Spartan.albumsAreSaved(albumIds: albumIds, success: { (savedBools) in\n    // Do something with the savedBools    \n}, failure: { (error) in\n    print(error)    \n})\n```\n\n#### [Get a User’s Top Artists and Tracks](https://developer.spotify.com/web-api/get-users-top-artists-and-tracks/)\n\n```swift\n_ = Spartan.albumsAreSaved(albumIds: albumIds, success: { (savedBools) in\n    // Do something with the savedBools    \n}, failure: { (error) in\n    print(error)    \n})\n```\n\n#### [Check User’s Saved Albums](https://developer.spotify.com/web-api/check-users-saved-albums/)\n\n```swift\n_ = Spartan.albumsAreSaved(albumIds: albumIds, success: { (savedBools) in\n    // Do something with the savedBools    \n}, failure: { (error) in\n    print(error)    \n})\n```\n\n#### [Get a User’s Top Artists](https://developer.spotify.com/web-api/get-users-top-artists-and-tracks/)\n\n```swift\n_ = Spartan.getMyTopArtists(limit: 20, offset: 0, timeRange: .mediumTerm, success: { (pagingObject) in\n\t// Get the artists via pagingObject.items\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get a User’s Top Tracks](https://developer.spotify.com/web-api/get-users-top-artists-and-tracks/)\n\n```swift\n_ = Spartan.getMyTopTracks(limit: 20, offset: 0, timeRange: .mediumTerm, success: { (pagingObject) in\n\t// Get the tracks via pagingObject.items\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get a List of a User’s Playlists](https://developer.spotify.com/web-api/get-list-users-playlists/)\n\n```swift\n_ = Spartan.getUsersPlaylists(userId: userId, limit: 20, offset: 0, success: { (pagingObject) in\n\t// Get the playlists via pagingObject.playlists\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get a List of Current User’s Playlists](https://developer.spotify.com/web-api/get-a-list-of-current-users-playlists/)\n\n```swift\n_ = Spartan.getMyPlaylists(limit: 20, offset: 0, success: { (pagingObject) in\n\t// Get the playlists via pagingObject.items\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get a Playlist](https://developer.spotify.com/web-api/get-playlist/)\n\n```swift\n_ = Spartan.getUsersPlaylist(userId: userId, playlistId: playlistId, fields: fields, market: .us, success: { (playlist) in\n\t// Do something with the playlist\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Get a Playlist's Tracks](https://developer.spotify.com/web-api/get-playlists-tracks/)\n\n```swift\n_ = Spartan.getPlaylistTracks(userId: userId, playlistId: playlistId, limit: 20, offset: 0, fields: fields, market: .us, success: { (pagingObject) in\n\t// Get the playlist tracks via pagingObject.items\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Create a Playlist](https://developer.spotify.com/web-api/create-playlist/)\n\n```swift\n_ = Spartan.createPlaylist(userId: userId, name: name, isPublic: true, isCollaborative: true, success: { (playlist) in\n\t// Do something with the playlist\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Change a Playlist’s Details](https://developer.spotify.com/web-api/change-playlist-details/)\n\n```swift\n_ = Spartan.changePlaylistDetails(userId: userId, playlistId: playlistId, name: name, isPublic: false, isCollaborative: false, success: {\n\t// The playlist details are now changed\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Add Tracks to a Playlist](https://developer.spotify.com/web-api/add-tracks-to-playlist/)\n\n```swift\n_ = Spartan.addTracksToPlaylist(userId: userId, playlistId: playlistId, trackUris: trackUris, success: { (snapshot) in\n\t// Do something with the snapshot\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Remove Tracks from a Playlist](https://developer.spotify.com/web-api/remove-tracks-playlist/)\n\n```swift\n_ = Spartan.removeTracksFromPlaylist(userId: userId, playlistId: playlistId, trackUris: trackUris, success: { (snapshot) in\n\t// Do something with the snapshot\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Reorder a Playlist’s Tracks](https://developer.spotify.com/web-api/reorder-playlists-tracks/)\n\n```swift\n_ = Spartan.reorderPlaylistsTracks(userId: userId, playlistId: playlistId, rangeStart: rangeStart, rangeLength: rangeLength, insertBefore: insertBefore, snapshotId: snapshotId, success: { (snapshot) in\n\t// Tracks are now reordered\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Replace a Playlist’s Tracks](https://developer.spotify.com/web-api/replace-playlists-tracks/)\n\n```swift\n_ = Spartan.replacePlaylistsTracks(userId: userId, playlistId: playlistId, trackUris: trackUris, success: {\n\t// Tracks are now replaced in playlist\n}, failure: { (error) in\n\tprint(error)\n})\n```\n\n#### [Check if Users Follow a Playlist](https://developer.spotify.com/web-api/check-user-following-playlist/)\n\n```swift\n_ = Spartan.getUsersAreFollowingPlaylists(ownerId: ownerId, playlistId: playlistId, userIds: userIds, success: { (followings) in\n\t// Do something with the followings\n}) { (error) in\n\tprint(error)\n}\n```\n\n\n\n\n\n\n\n## Handling Errors\n\nSpartanError objects have a type and error message to help determine what kind of error occurred.\n\n```swift\npublic class SpartanError: NSObject, Mappable {\n    private(set) open var type: SpartanErrorType!\n    private(set) open var errorMessage:String!\n}\n```\n\nIf a request suceeds but is invalid, the erorrMessage will be the error message returned directly from Spotify.\n\nFor example, if the Spotify error response is:\n\n```swift\n{\n  \"error\": {\n    \"status\": 401,\n    \"message\": \"Invalid access token\"\n  }\n}\n```\n\nThe SpartanError object within a failure callback will be:\n\n```swift\n_ = Spartan.getMe(success: { (user) in\n\n}, failure: { (error) in\n\tprint(error.errorType)     // .unauthorized\n\tprint(error.errorMessage)  // \"Invalid access token\"\n})\n```\n\nSo if your access token is expired, you could do something like this:\n\n```swift\n_ = Spartan.getMe(success: { (user) in\n\n}, failure: { (error) in\n\tif error.errorType == .unauthorized {\n\t\t// Refresh your access token and try again\n\t}\n})\n```\n\n## Library Dependencies\n\n - [Alamofire](https://github.com/Alamofire/Alamofire): Elegant HTTP Networking in Swift\n - [AlamofireObjectMapper](https://github.com/tristanhimmelman/AlamofireObjectMapper): An Alamofire extension which converts JSON into Swift objects\n\n## Usage Information and Limits\n\nSince Spartan is built on top of the Spotify Web API, [click here for more information](https://developer.spotify.com/web-api/user-guide/#rate-limiting)\n\n## Author\n\nDalton Hinterscher, daltonhint4@gmail.com\n\n## License\n\nSpartan is available under the MIT license. See the LICENSE file for more info.\n","funding_links":["https://github.com/sponsors/daltron"],"categories":["SDK"],"sub_categories":["Unofficial","Other free courses"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDaltron%2FSpartan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDaltron%2FSpartan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDaltron%2FSpartan/lists"}