All Projects → vpaliy → Last.fm Api

vpaliy / Last.fm Api

Licence: mit
Last.fm API wrapped into a bunch of classes. Built with OkHttp, Retrofit2, RxJava2.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Last.fm Api

Mvvmarms
Android MVVM Architecture Components based on MVPArms and Android Architecture Components.
Stars: ✭ 425 (+936.59%)
Mutual labels:  rxjava2, retrofit2
Doubanmovie
豆瓣电影API全网最新最全解析
Stars: ✭ 38 (-7.32%)
Mutual labels:  rxjava2, retrofit2
Bilisoleil
An unofficial bilibili client for android --rxjava2+mvp+okhttp3+retrofit2+dagger2
Stars: ✭ 430 (+948.78%)
Mutual labels:  rxjava2, retrofit2
Paonet
【MVVM+RxJava2+AspectJ】泡网第三方客户端,网站主页:http://www.jcodecraeer.com/index.php
Stars: ✭ 374 (+812.2%)
Mutual labels:  rxjava2, retrofit2
Repofactory
A flexible solution for creating a repository pattern
Stars: ✭ 16 (-60.98%)
Mutual labels:  rxjava2, retrofit2
Mvvmsmart
基于谷歌最新AAC架构,MVVM设计模式的一套快速开发库,整合ViewModel+Lifecycles+Navigation+DataBinding+LiveData+Okhttp+Retrofit+RxJava+Glide等主流模块,满足日常开发需求。使用该框架可以快速开发高质量、易维护的Android应用。 项目组会持续维护,请放心使用.欢迎Start并Fork交流.
Stars: ✭ 382 (+831.71%)
Mutual labels:  rxjava2, retrofit2
Cloudreader
🗡️ 云阅:一款基于网易云音乐UI,使用玩Android Api,Retrofit2 + RxJava2 + Room + MVVM-databinding架构开发的Android客户端
Stars: ✭ 4,611 (+11146.34%)
Mutual labels:  rxjava2, retrofit2
Kotlinmvp
🔥 基于Kotlin+MVP+Retrofit+RxJava+Glide 等架构实现短视频类小项目,简约风格及详细注释,欢迎 star or fork!
Stars: ✭ 3,488 (+8407.32%)
Mutual labels:  rxjava2, retrofit2
Mvvmhabit
goldze: 本人喜欢尝试新的技术,以后发现有好用的东西,我将会在企业项目中实战,没有问题了就会把它引入到MVVMHabit中,一直维护着这套框架,谢谢各位朋友的支持。如果觉得这套框架不错的话,麻烦点个 star,你的支持则是我前进的动力!
Stars: ✭ 6,789 (+16458.54%)
Mutual labels:  rxjava2, retrofit2
Ganhuoio
基于Gank.IO提供的API的第三方客户端(RxJava+Retrofit)
Stars: ✭ 727 (+1673.17%)
Mutual labels:  rxjava2, retrofit2
Androidproject
Android 技术中台,但愿人长久,搬砖不再有
Stars: ✭ 4,398 (+10626.83%)
Mutual labels:  rxjava2, retrofit2
Bestnote
👊 持续更新,Java Android 近几年最全面的技术点以及面试题 供自己学习使用
Stars: ✭ 841 (+1951.22%)
Mutual labels:  rxjava2, retrofit2
Seeweather
⛅ [@deprecated]RxJava+RxBus+Retrofit+Glide+Material Design Weather App
Stars: ✭ 3,481 (+8390.24%)
Mutual labels:  rxjava2, retrofit2
Devring
安卓基础开发库,包含各常用模块,让开发简单点。
Stars: ✭ 414 (+909.76%)
Mutual labels:  rxjava2, retrofit2
Rx Mvp
RxJava2+Retrofit2+RxLifecycle2+OkHttp3 封装RHttp 使用MVP模式构建项目
Stars: ✭ 343 (+736.59%)
Mutual labels:  rxjava2, retrofit2
V9porn
9*Porn Android 客户端,突破游客每天观看10次视频的限制,还可以下载视频
Stars: ✭ 4,507 (+10892.68%)
Mutual labels:  rxjava2, retrofit2
Moviehub
Showcases popular movies, tv shows, and people from The Movie Database
Stars: ✭ 325 (+692.68%)
Mutual labels:  rxjava2, retrofit2
News Sample App
A sample news app which demonstrates clean architecture and best practices for developing android app
Stars: ✭ 334 (+714.63%)
Mutual labels:  rxjava2, retrofit2
Offlinesampleapp
Sample Offline-First MVVM app that uses Android Priority Job Queue, Room, Retrofit2, LiveData, LifecycleObserver, RxJava2, Dagger Android
Stars: ✭ 653 (+1492.68%)
Mutual labels:  rxjava2, retrofit2
Base Mvvm
App built to showcase basic Android View components like ViewPager, RecyclerView(homogeneous and heterogeneous items), NavigationDrawer, Animated Vector Drawables, Collapsing Toolbar Layout etc. housed in a MVVM architecture
Stars: ✭ 18 (-56.1%)
Mutual labels:  rxjava2, retrofit2

last.fm API

This project is a wrapper for the Last.fm API. The last.fm API allows anyone to build their applications using the last.fm data.

Here's the list of the most useful things you can do with this API:

  • get artists, tags, albums, users, tracks, charts
  • get the most popular items (artists,tracks,albums,tags)
  • get info of an item.
  • get a list of the most popular artists or tracks by a country name.
  • add/remove a tag to/from an artist, track, album
  • like/unlike a track
  • retrieve data from a user (favorite items,tracks, albums, info, recent tracks, charts)
  • search for an item.
  • log in/log out

How do I use this wrapper?

Step 1

Add this to your root build.gradle file:

allprojects {
  repositories {
     maven { url 'https://jitpack.io' }
  }
}

Step 2

Add the dependency

dependencies {
     compile 'com.github.vpaliyX:Last.fm-API:v1.2.0'
}

Nuts and Bolts

This wrapper is built with Retrofit2 and RxJava2. Basically, the wrapper is divided into 3 main abstractions:

  • Authentication - authentication of a user, provides a session key.
  • Update Service - all write requests (POST).
  • Last.fm Service - all read requests (GET).

Regardless of which request you want to make, you will need to have an API_KEY and a SECRET_KEY. You can obtain this here, it takes only 2 min to get it.

Note Due to the complex structure of JSON data returned by the web service, all requests are using a wrapper called Response which is the response of a request. Just access the Response.result field of that object, and you will get your desired data.

Authentication

It's super simple.

First of all, last.fm provides you with a session key which never expires. This way you don't have to refresh this at all. Once you have obtained you session key, you can do any of the POST requests.

Secondly, if you don't want to do POST requests, then you don't need a session key. You can skip this step since you won't need to have a session key for GET requests.

The LastFmAuth class is responsible for the authorization, it encapsulates some additional steps, you just need to provide a username and password. Once you've done that, you will receive a session key.

Here's how it should work:

LastFmAuth.create(Config.API_KEY,Config.API_SECRET)
      .auth(context,"username","password")
      .subscribeOn(Schedulers.io())
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(response -> {
          Session session=response.result;
       });

Note The Session object, which has been provided after the call, will be needed to perform POST requests, so you can just save it in the shared preferences with one helper method:

   SharedPreferences.Editor editor=pref.edit();
   editor.putString("key",Session.convertToString(session)).apply();

And if you need this again, you can just retrieve from your shared preferences:

Session session=Session.convertFromString(pref.getString("key",null));

Update Service

Here you need to provide only a Context and a Session object. You can access the write calls with the LastFmUpdate class, here is an example:

  LastFmUpdate.create(context,session)
      .addTagsToAlbum("artist","album","tag1","tag2","tag3")
      .subscribeOn(Schedulers.io())
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(()->{},Throwable::printStackTrace);

Also, you can use chains, so you can make a few requests at the same time:

LastFmUpdate.create(this,session)
       .startChain()
       .addTagsToAlbum("Imagine Dragons","Evolve","#favorite","#album")
       .addTagsToArtist("Imagine Dragons","#favorite","#lovely")
       .unloveTrack("Imagine Dragons","Demons")
       .loveTrack("Imagine Dragons","Whatever It Takes")
       .addTagsToTrack("Imagine Dragons","Rise Up","#summer2017")
       .addTagsToTrack("Imagine Dragons","Walking the Wire","#summer2017")
       .stop()
       .subscribeOn(Schedulers.io())
       .observeOn(AndroidSchedulers.mainThread())
       .subscribe(()->{},Throwable::printStackTrace);

Use the startChain() method to create a chain, and the stop() method to stop it.

All POST requests return a Completable object, which represents a deferred computation without any value but only indication for completion or exception. It's either success or failure when you subscribe to it.

Last.fm Service

You can access this service without any Session object. It just works.

Use the LastFm class to create the service:

 //get the service
 LastFmService service=LastFm.create(Config.API_KEY)
            .createService(this);
            
//request an artist      
service.fetchArtist("name of an artist")
      .subscribeOn(Schedulers.io())
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(response -> {
            Artist artist=response.result;
       });

Additional Documentation And Support

The End.

MIT License

Copyright (c) 2017 Vasyl Paliy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].