A Java Wrapper For Official Supercell Brawl Stars Api
A big sorry for that, but the quality of that scheme changes from day to day. Another big sorry, but the OpenApi Java generator is producing code quality we like much. That's simple why :) If you think the same way (it may differ from case to case of course), feel free to continue using our wrapper.
We moved to packagecloud.io because the bintray closed their nice hosting... And packagecloud.io is a really nice place to be :)
Note: Please combine the builder methods as it makes sense. The demonstrated is showing only all possibilities. For more information please check
https://developer.brawlstars.com/#/documentation
Use one of these endpoints:
Official endpoint
https://api.brawlstars.com/v1
Proxy endpoint
https://bsproxy.royaleapi.dev/v1
Bind essentials to your project
<repositories>
<repository>
<id>packagecloud-supercell-api-wrapper-essentials</id>
<url>https://packagecloud.io/mlieshoff/supercell-api-wrapper-essentials/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
and use the dependency
<dependency>
<groupId>supercell-api-wrapper-essentials</groupId>
<artifactId>supercell-api-wrapper-essentials</artifactId>
<version>1.0.1</version>
</dependency>
Use built-in standard connector
Connector connector = new StandardConnector();
or use the new filesystem cached connector
Connector connector = new FilesystemCachedConnector("brawljars")
or use custom implementation
Connector connector = new Connector() {
@Override
public <T extends IResponse> T get(RequestContext requestContext) throws ConnectorException {
// do not forget to use auth header with *Bearer*
String authHeader = "Authorization: Bearer " + requestContext.getApiKey();
}
}
);
connect to the api with creating a BrawlJars instance.
BrawlJars brawlJars = new BrawlJars("https://bsproxy.royaleapi.dev/v1", "my-api-key", connector);
list all supported apis
System.out.println(brawlJars.listApis());
// create an instance for the api
PlayerApi api = brawlJars.getApi(PlayerApi.class);
// findById
PlayerResponse response = api.findById(PlayerRequest.builder()
.playerTag()
// store raw response
.storeRawResponse()
.build()
).get();
// findBattleLog
BattleLogResponse response = api.findBattleLog(BattleLogRequest.builder()
.playerTag()
// pagination
.limit()
.after()
.before()
// store raw response
.storeRawResponse()
.build()
).get();
// create an instance for the api
ClubApi api = brawlJars.getApi(ClubApi.class);
// findClubMembers
ClubMembersResponse response = api.findClubMembers(clubMembersRequest.builder()
.clubTag()
// pagination
.limit()
.after()
.before()
// store raw response
.storeRawResponse()
.build()
).get();
// findClub
ClubResponse response = api.findClub(clubRequest.builder()
.clubTag()
// store raw response
.storeRawResponse()
.build()
).get();
// create an instance for the api
RankingApi api = brawlJars.getApi(RankingApi.class);
// findPowerplayRankings
PowerplayRankingsResponse response = api.findPowerplayRankings(powerplayRankingsRequest.builder()
.countryCode()
.seasonId()
// pagination
.limit()
.after()
.before()
// store raw response
.storeRawResponse()
.build()
).get();
// findPowerplayRankingsSeasons
PowerplayRankingsSeasonsResponse response = api.findPowerplayRankingsSeasons(powerplayRankingsSeasonsRequest.builder()
.countryCode()
// pagination
.limit()
.after()
.before()
// store raw response
.storeRawResponse()
.build()
).get();
// findClubRankings
ClubRankingsResponse response = api.findClubRankings(clubRankingsRequest.builder()
.countryCode()
// pagination
.limit()
.after()
.before()
// store raw response
.storeRawResponse()
.build()
).get();
// findBrawlerRankings
BrawlerRankingsResponse response = api.findBrawlerRankings(brawlerRankingsRequest.builder()
.countryCode()
.brawlerId()
// pagination
.limit()
.after()
.before()
// store raw response
.storeRawResponse()
.build()
).get();
// findPlayerRankings
PlayerRankingsResponse response = api.findPlayerRankings(playerRankingsRequest.builder()
.countryCode()
// pagination
.limit()
.after()
.before()
// store raw response
.storeRawResponse()
.build()
).get();
// create an instance for the api
BrawlerApi api = brawlJars.getApi(BrawlerApi.class);
// findAll
BrawlersResponse response = api.findAll(brawlersRequest.builder()
// pagination
.limit()
.after()
.before()
// store raw response
.storeRawResponse()
.build()
).get();
// findById
BrawlerResponse response = api.findById(brawlersRequest.builder()
.brawlerId()
// store raw response
.storeRawResponse()
.build()
).get();
// create an instance for the api
EventApi api = brawlJars.getApi(EventApi.class);
// findEventRotation
EventRotationResponse response = api.findEventRotation(eventRotationRequest.builder()
// store raw response
.storeRawResponse()
.build()
).get();
BrawlJars brawlJars = new BrawlJars(...);
brawlJars.register(MyApi.class, MyApiImpl.class.getName());
MyApi myApi = brawlJars.getApi(MyApi.class);
GoodiesResponse goodiesResponse = myApi.findAllGoodies(new GoodiesRequest(...))).get();
Custom API implementations just need to inherit from BaseApi.
All requests are returning java.concurrent.Future. The execution will be asynchronous by default.
<repositories>
<repository>
<id>packagecloud-brawljars</id>
<url>https://packagecloud.io/mlieshoff/brawljars/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
to Gradle:
implementation group: 'brawljars', name: 'brawljars', version: '4.0.2'
to Maven:
<dependency>
<groupId>brawljars</groupId>
<artifactId>brawljars</artifactId>
<version>4.0.2</version>
</dependency>
https://github.com/mlieshoff/brawljars/actions
https://packagecloud.io/mlieshoff/brawljars
We are using SLF4j.
This wrapper can be easyly connected to the proxy of our friends on RoyaleAPI. Please proceed first the steps described here:
https://docs.royaleapi.com/#/proxy
Then initialize an instance of class Api like that:
BrawlJars brawlJars = new BrawlJars("https://bsproxy.royaleapi.dev/v1", API_KEY, CONNECTOR);
That's all, enjoy :)
Minor versions
mvn versions:update-parent versions:use-latest-releases versions:update-properties versions:commit -DallowMajorUpdates=false
Major versions
mvn versions:update-parent versions:use-latest-releases versions:update-properties versions:commit -DallowMajorUpdates=true
Update plugins
mvn versions:display-plugin-updates -U
- Feel free to open Pull Requests with your ideas :)