Code Monkey home page Code Monkey logo

java-champion-gg-wrapper's Introduction

Build Status Codacy Grade Codacy Coverage GitHub Release Version Maven Version License

java-champion-gg-wrapper

A simple Java wrapper for the ChampionGG API (http://api.champion.gg/docs/). This wrapper is not yet updated for Version 2.0.0 of the ChampionGG API. I will do this some time. Currently the API documentation is missing some information and because of this, the updating process is taking quite some time.

Features

  • Automatic rate limiting: All API calles can easily be rate limited. All API instances created with the same factory share one rate limiter. The number of requests per second can freely be set as the second parameter of the factory constructor. A value of 0 or a negative value disables the rate limiting. The default is no rate limiting.
  • Asyncronous calls: Calls return immediately and other calculation can be done while waiting for the result (or more API calls can be started). The response provides a waitForResponse method to easily wait for an result once its required.
  • Fully tested: Maybe not strictly a feature but all API methods get tested with mocked data (which was previously directly pulled from the API)
  • Complete: Maybe also not strictly a feature but all API methods provided by the ChampionGG API are currently implemented.

Usage

All you have to do is add the dependency to your maven project:

<dependencies>
    <dependency>
        <groupId>com.lvack</groupId>
        <artifactId>champion-gg-wrapper</artifactId>
        <version>{version}</version>
    </dependency>
</dependencies>

If you do not use maven, the jars can be found in the releases. In case you want a jar without the included dependencies, you can download them from maven central (latest version).

Then the usage is pretty straight forward:

ChampionGGAPIFactory factory = new ChampionGGAPIFactory("API_KEY", 10); // do at most 10 requests per second
ChampionGGAPI api = factory.buildChampionGGAPI();

APIResponse<List<HighLevelChampionData>> response = api.getHighLevelChampionData();
response.waitForResponse();

if (response.isSuccess()) {
    List<HighLevelChampionData> content = response.getContent();
    HighLevelChampionData data = content.get(0);

    System.out.println("Champion: " + data.getName());
    for (RoleData roleData : data.getRoles()) {
        System.out.println("- Position: " + roleData.getRole());
        System.out.println(String.format("  - Played %04.1f%% (%d games) of the time in this role",
            roleData.getPercentPlayed(), roleData.getGameCount()));
    }
} else {
    // something went wrong

    // the api returned an error
    if (response.isAPIError()) System.out.println(response.getErrorResponse());

    // an exception was thrown somewhere in the process
    if (response.isFailure()) response.getError().printStackTrace();

    if (response.isInvalidAPIKey()) System.out.println("Invalid API key!");
}

java-champion-gg-wrapper's People

Contributors

logicaloverflow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

rodrigamen

java-champion-gg-wrapper's Issues

Any updates coming?

Hey there i'm working on a discord bot atm and i would like to know if there is a newer version of the wrapper currently in work? I could also help if you want ๐Ÿ˜„

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.