项目作者: woojiahao

项目描述 :
Java wrapper for the Spotify web API
高级语言: Kotlin
项目地址: git://github.com/woojiahao/java-spotify-wrapper.git
创建时间: 2018-10-09T02:20:58Z
项目社区:https://github.com/woojiahao/java-spotify-wrapper

开源协议:MIT License

下载


Java Spotify Wrapper

Simple to use Java wrapper for the Spotify web API

IMPORTANT: The library is still under development, you can check out what needs to be completed in the checklist below. Only some of the endpoints and authentication flow has been
completed.

Contents

  1. Anonymous Access
  2. Sample Usage
  3. User Authentication
  4. Examples
  5. Contributing
  6. License
  7. Checklist

Anonymous Access

Some of Spotify’s Web API is available to users even without an access token or performing any form of user authentication,
the library supports the access of these resources.

Sample Usage

In order to begin using the Spotify API, you have to create what is known as a SpotifyUser. This can be done either
by following a flow and generating one, or
manually creating one yourself:

  1. SpotifyUser oneTimeUser = new SpotifyUser("<access_token>");
  2. SpotifyUser refreshUser = new SpotifyUser("<access_token>", "refresh_token");

After that, you can proceed to apply the methods you wish to use on this SpotifyUser object.

Example: Getting an album

  1. Album album = oneTimeUser.getAlbum("0sNOF9WDwhWunNAHPD3Baj").build().execute();
  2. System.out.println(album.getArtist());

Example: Generating recommendations based off a seed

  1. Recommendation recommendation = oneTimeUser
  2. .getSeedRecommendation()
  3. .limit(5)
  4. .addSeedGenre("party")
  5. .setSeedArtists(listOf("4NHQUGzhtTLFvgF5SZesLK", "43ZHCT0cAZBISjO8DG9PnE"))
  6. .danceability(SeedQuery.Flag.Min, 0.6)
  7. .build()
  8. .execute();
  9. recommendation.getSeeds().forEach(System.out::println);

More information:

User Authentication

The Spotify Web API offers 3 methods of user authentication.

The library offers means to authenticate users in all 3 ways.

Authorization Flow

This form of authorization is used when you need to have a persistent session for the user and want the user to be
able to continually access the API without having to authorize themselves everytime their access token expires.

Example implementation of the authorization flow using the library

More information about the process steps

Implicit Grant

This method of user authentication is recommended if the information you want to retrieve from the user’s account is
one-time and you won’t need a persistent connection.

Example implementation of the implicit grant flow using the library

More information about the process steps

Client Credentials

This method of user authentication is used for server-to-server communication and does not require any authorization.
However, because of that, there is no refresh token provided.

Example implementation of the client credential flow using the library

More information about the process steps

Contributing

The project’s code of conduct can be found here.

If you wish to make a contribution, be sure to read the contribution guide.

Examples

License

java-spotify-wrapper is licensed under the MIT license, more about that can be found here.

Checklist

  • Endpoints
    • [X] Album
    • [X] Artist
    • [X] Browse
    • [X] Follow
    • [X] Library
    • [X] Personalization
    • [X] Player
    • [X] Playlists
    • Search
    • [X] Tracks
    • [X] User Profile
  • Administrative
    • [X] Contribution Guide
    • Deploy to Maven Central
    • Include instructions to install in Maven if possible
    • Issues Templates
      • Bug Reporting
      • Feature
    • PR Templates
    • Documentation Templates
  • Sample Application
  • Testing
    • CI
    • Unit Tests