Skip to content
/ elypiai Public mirror
mirrored from https://gitlab.com/Elypia/elypiai

Elypiai is a collection of projects that wrap around various web APIs that don't provide official libraries for Java. [This is a mirror from GitLab, please interact with the repository there.]

License

Notifications You must be signed in to change notification settings

elypia/elypiai

Elypiai

Matrix Discord Maven Central Docs Build Coverage Donate

About

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!

Supported APIs

You can check the issues to see pending wrappers.

Why are these wraps in a single repository?

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.

Getting Started

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));
    }
}

Support

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.

About

Elypiai is a collection of projects that wrap around various web APIs that don't provide official libraries for Java. [This is a mirror from GitLab, please interact with the repository there.]

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Languages