Skip to content

mlieshoff/jcrapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java CR-API Connector

Sunset of API

Due to sunset of the cr-api service (https://royaleapi.com/blog/sunset-api) this wrapper will not be continued anymore. Insstead to use jcrapi, please use jcrapi2 (https://github.com/mlieshoff/jcrapi2) which is a wrapper for the official api from Supercell. You can use that new wrapper also in combination with proxy of cr-api creators.

Actual version: v12.0.236-RC5

Simplest Usage

Note: Please combine the builder methods as it makes sense. The demonstrated was is showing only all possibilities. For more information please check

https://docs.royaleapi.com

// connect to api
Api api = new Api("http://api.royaleapi.com/", "my-developer-key"); // standard auth mode
Api api = new Api("http://api.royaleapi.com/", "my-developer-key", AuthMode.BEARER);
// get version
String version = api.getVersion();
// get profile
Profile profile = api.getProfile(ProfileRequest.builder("2PGGCJJL")
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("battles"))
    .build()
);
// get profiles
List<Profile> profiles = api.getProfiles(ProfilesRequest.builder(Arrays.asList("L88P2282", "9CQ2U8QJ", "8L9L9GL"))
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("battles"))
    .limit(10)
    .max(5)
    .page(2)
    .build()
);
// get clan
Clan clan = api.getClan(ClanRequestBuilder.builder("RP88QQG")
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("battles"))
    .build());
// get list of clans
List<Clan> clans = api.getClans(ClanRequestBuilder.builder(Arrays.asList("RP88QQG", "2CCCP"))
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("battles"))
    .limit(10)
    .max(5)
    .page(2)
    .build());
// clan search
List<Clan> clans = api.getClanSearch(ClanSearchRequest.builder()
    .setName("abc")
    .setScore(500)
    .setMinMembers(10)
    .setMaxMembers(25)
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("battles"))
    .limit(10)
    .max(5)
    .page(2)
    .build());
// get tournaments
Tournament tournament = api.getTournaments(TournamentRequest.builder()
    .tag("XYZHHG")
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("battles"))
    .build());
// get top clans
List<TopClan> topClansForEu = api.getTopClans(TopClanRequest.builder()
    .locationKey("EU")
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("battles"))
    .limit(10)
    .max(5)
    .page(2)
    .build());
// get top players
List<TopPlayer> topPlayersForEu = api.getTopPlayers(TopPlayerRequest.builder()
    .locationKey("EU")
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("battles"))
    .limit(10)
    .max(5)
    .page(2)
    .build());
// get top Wars
List<TopWar> topWarsForEu = api.getTopWars(TopWarRequest.builder()
    .locationKey("EU")
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("battles"))
    .limit(10)
    .max(5)
    .page(2)
    .build());
// get endpoints
Endpoints endpoints = api.getEndpoints();
// get popular clans
List<PopularClan> popularClans = api.getPopularClans(PopularClans.builder()
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("battles"))
    .limit(10)
    .max(5)
    .page(2)
    .build());
// get popular players
List<PopularPlayer> popularPlayers = api.getPopularPlayers(PopularPlayers.builder()
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("battles"))
    .limit(10)
    .max(5)
    .page(2)
    .build());
// get popular tournaments
List<PopularTournament> popularTournaments = api.getPopularTournaments(PopularTournaments.builder()
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("battles"))
    .limit(10)
    .max(5)
    .page(2)
    .build());
// get clan battles
List<Battle> clanBattles = api.getClanBattles(ClanBattleRequest.builder("RP88QQG")
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("cards"))
    .limit(10)
    .max(5)
    .page(2)
    .build());
// get clan history
ClanHistory clanHistory = api.getClanHistory(ClanHistoryRequest.builder("RP88QQG")
    .days(1)
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("cards"))
    .limit(10)
    .max(5)
    .page(2)
    .build());
// get clan weekly history
ClanWeeklyHistory clanWeeklyHistory = api.getClanWeeklyHistory(ClanWeeklyHistoryRequest.builder("RP88QQG")
    .days(1)
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("cards"))
    .limit(10)
    .max(5)
    .page(2)
    .build());
// get clan war log
List<ClanWarLog> clanWarLogs = api.getClanWarLog(ClanWarLogRequest.builder("RP88QQG")
    .tag("RP88QQG");
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("cards"))
    .limit(10)
    .max(5)
    .page(2)
    .build());
// get clan war
ClanWar clanWar = api.getClanWarLog(ClanWarRequest.builder("RP88QQG")
    .tag("RP88QQG");
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("cards"))
    .build());
// get open tournaments
List<OpenTournament> openTournaments = api.getOpenTournaments(OpenTournamentsRequest.builder()
    .oneK(true)
    .open(true)
    .full(true)
    .prep(true)
    .joinable(true)
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("cards"))
    .limit(10)
    .max(5)
    .page(2)
    .build());
// get known tournaments
List<KnownTournament> knownTournaments = api.getKnownTournaments(KnownTournamentsRequest.builder()
    .oneK(true)
    .open(true)
    .full(true)
    .prep(true)
    .joinable(true)
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("cards"))
    .limit(10)
    .max(5)
    .page(2)
    .build());
// get 1k tournaments
List<OneKTournament> oneKTournaments = api.getOneKTournaments(OneKTournamentsRequest.builder()
    .oneK(true)
    .open(true)
    .full(true)
    .prep(true)
    .joinable(true)
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("cards"))
    .limit(10)
    .max(5)
    .page(2)
    .build());
// get full tournaments
List<FullTournament> fullTournaments = api.getFullTournaments(FullTournamentsRequest.builder()
    .oneK(true)
    .open(true)
    .full(true)
    .prep(true)
    .joinable(true)
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("cards"))
    .limit(10)
    .max(5)
    .page(2)
    .build());
// get in preparation tournaments
List<InPreparationTournament> inPreparationTournaments = api.getInPreparationTournaments(InPreparationTournamentsRequest.builder()
    .oneK(true)
    .open(true)
    .full(true)
    .prep(true)
    .joinable(true)
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("cards"))
    .limit(10)
    .max(5)
    .page(2)
    .build());
// tournament search
List<Clan> clans = api.getTournamentSearch(TournamentSearchRequest.builder()
    .setName("abc")
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("battles"))
    .limit(10)
    .max(5)
    .page(2)
    .build());
// get player battles
List<List<Battle>> battles = api.getPlayerBattles(PlayerBattlesRequest.builder(Arrays.asList("L88P2282", "9CQ2U8QJ", "8L9L9GL"))
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("cards"))
    .limit(10)
    .max(5)
    .page(2)
    .build());
// get player chests
List<ChestCycle> chestCycles = api.getPlayerChests(PlayerChestsRequest.builder(Arrays.asList("L88P2282", "9CQ2U8QJ", "8L9L9GL"))
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("cards"))
    .limit(10)
    .max(5)
    .page(2)
    .build());
// get popular decks
List<PopularDeck> popularDecks = api.getPopularDecks(PopularDecksRequest.builder()
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("cards"))
    .limit(10)
    .max(5)
    .page(2)
    .build());
// get clan tracking
ClanTracking clanTracking = api.getClanTracking(ClanTrackingRequest.builder()
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("cards"))
    .build());
// get auth stats
AuthStats authStats = api.getAuthStats(AuthStatsRequest.builder()
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("cards"))
    .build());
// get constants
Constants constants = api.getConstants(ConstantsRequest.builder()
    .keys(Arrays.asList("name", "clan", "tag"))
    .excludes(Arrays.asList("battles"))
    .limit(10)
    .max(5)
    .page(2)
    .build());
// get status
Status status = api.getStatus();
// get health
String health = api.getHealth();
// get thread safe last response object from last request 
Response response = api.getLastResponse();

String raw = response.getRaw();
Map<String, String> responseHeaders = response.getResponseHeaders();
int rateLimit = response.getRateLimit();
int rateRemaining = response.getRateRemaining();

How to bind the bintray repository

<repository>
    <id>org-mili-repo</id>
    <url>http://dl.bintray.com/mlieshoff/maven</url>
    <releases>
        <enabled>true</enabled>
    </releases>
    <snapshots>
        <enabled>false</enabled>
    </snapshots>
</repository>

Continuous Integration

https://travis-ci.org/mlieshoff/jcrapi

Repository

https://bintray.com/mlieshoff/maven/jcrapi