Elypiai is a small and easy way, especially for new developers, to add ample functionality or integrations to any project.
We wrap web APIs that don't provide an official binding for Java and make a module for each one with a consistent interface between each.
The Gradle/Maven import strings can be found at the maven-central badge above!
- Cleverbot - Complete
- Companies House - WIP
- Mojang - WIP
- Orna Guide - WIP
- osu! - WIP
- Path of Exile - Complete
- RuneScape - WIP
- Steam - WIP
- Urban Dictionary - Complete
- Yu-Gi-Oh! Prices - WIP
- Weblate - WIP
You can check the issues to see pending wrappers.
Rather than making a Cleverbot4J, Orna4J, osu!4J, etc project we've opted for a submodule approach. The reason for this is because all submodules in this repository has an almost identical structure to them, and when we want to make major alterations to how we want to make requests, we often want to change it for all of our wrappers. Please visit the appropriate README of the module you're interested in.
In this example we'll just use the osu! API to get things going.
First you need to construct the wrapper object for the API you want to access, for example. Following this you can use the methods as you'd expect, each API method will have a few ways to make the request:
blockingGet()
- This will do a synchronous or blocking request and return an optional object.subscribe(success, failure)
- This will do an asynchronous request, both the success, and failure consumers are optional.
public class Main {
private final Osu osu;
/**
* Start by instantiating the wrapper to use, then call
* a request method. Wrappers will accept whatever they need
* in their constructor and can have their OkHttpClient instance
* updated to accommodate custom interceptors.
*/
public static void main(String[] args) {
osu = new Osu("{{api key}}");
}
/**
* RxJava is pretty flexible; you can call #subscribe
* with callbacks to handle the result asynchronously,
* all the parameters are optional, or call #blockingGet
* to handle it synchronously.
*/
public static void simpleExample() {
osu.getPlayer("SethX3").subscribe(
(player) -> System.out.println(player),
(ex) -> ex.printStacktrace(),
() -> System.out.println("That player didn't exist.")
);
Player player = osu.getPlayer("SethX3").blockingGet();
}
/**
* It's even possible to perform batch requests!
*/
public static void batchExample() {
List<Observable<Player>> requests = Stream.of("SethX3", "Rheannon")
.map(osu::getPlayer)
.map(Maybe::toObservable)
.collect(Collectors.toList());
Observable<List<Player>> singlePlayers = Observable.zip(requests, (objects) ->
Stream.of(objects).map((o) -> (Player)o).collect(Collectors.toList())
);
singlePlayers.subscribe((players) -> players.forEach(System.out::println));
}
}
If you have any questions or need support, come visit us on Matrix! We're always around and there are ample developers that would be willing to help; if it's a problem with the library itself then we'll make sure to get it sorted.