Easy to use library, available to both Kotlin and Java.
A wrapper for the different endpoints Riot API provides, using Retrofit/OKHttp libraries.
Support synchronous and asynchronous call.
Simply put your API key and go !
app or module build.gradle
repositories {
mavenCentral()
}
module build.gradle
implementation "io.github.miniclem:kotlin-api-riot-wrapper:0.3"
<dependency>
<groupId>io.github.miniclem</groupId>
<artifactId>kotlin-api-riot-wrapper</artifactId>
<version>0.3</version>
</dependency>
ClientApi.apply {
// You must provide your API key,
tokenProvider = ParamProperties()
}
// OR simply put
ClientApi.apply {
tokenProvider = object : TokenProvider {
override fun getToken(): String {
return "YOUR API KEY"
}
}
}
ClientApi.championV3(PlatformRoutes.EUW1).getChampionRotations().enqueue(object : Callback<ChampionInfo> {
override fun onFailure(call: Call<ChampionInfo>, t: Throwable) {
// Call the bott... backends noobs
t.printStackTrace()
}
override fun onResponse(call: Call<ChampionInfo>, response: Response<ChampionInfo>) {
response.body()?.let {
// Jungle around your data
}
}
})
ClientApi.INSTANCE.setTokenProvider(new TokenProvider() {
@NotNull
@Override
public String getToken() {
return "YOUR API KEY";
}
});
ClientApi.INSTANCE.championV3(PlatformRoutes.EUW1).getChampionRotations().enqueue(new retrofit2.Callback<ChampionInfo>() {
@Override
public void onResponse(@NotNull Call<ChampionInfo> call, @NotNull Response<ChampionInfo> response) {
// Use your response data
}
@Override
public void onFailure(@NotNull Call<ChampionInfo> call, @NotNull Throwable t) {
t.printStackTrace();
}
});
You must provide a way for your app to authenticate via the Riot API portal using you API key.
See the official site Riot developer portal
Back to the library you will need to implement the TokenProvider
interface and pass it to the ClientApi
.
class ParamProperties : Properties(), TokenProvider {
init {
val inputStream = ClassLoader.getSystemResourceAsStream("param.properties")
if (inputStream != null)
load(inputStream)
else throw IOException("You must create a file named 'param.properties' in the resource folder containing at least the 'TOKEN' variable with your API token")
}
override fun getToken(): String {
return getProperty("TOKEN")
}
}
param.properties:
TOKEN=YOUR API KEY HERE
- CHAMPION-MASTERY-V4
- CHAMPION-V3
- CLASH-V1
- LEAGUE-EXP-V4
- LEAGUE-V4
- LOL-STATUS-V3
- MATCH-V4
- SPECTATOR-V4
- SUMMONER-V4
- THIRD-PARTY-CODE-V4
- TOURNAMENT-STUB-V4
- ACCOUNT-V1
- VAL-MATCH-V1
- TFT-LEAGUE-V1
- TFT-MATCH-V1
- TFT-SUMMONER-V1
- LOR-RANKED-V1
Feel free to post issues while you find one, I would gladly try to fix it or accept pull request :)