Getting started
This will teach you how to use the API, including all features.
Go ahead and create a new class within your project folder. This class needs to have a main method to run the example code, you can then adjust it to your own needs. Within your main method you will need to load up the API. You can then create a new instance of the API, which is used for the required methods.
I recommend putting this API into a class variable, and pass it on into classes where you need them.
import me.kazury.enkanetworkapi.enka.EnkaNetworkAPI;
public class Main {
public static void main(String[] args) {
final EnkaNetworkAPI api = new EnkaNetworkAPI().build();
}
}Blocking specific caches
For some people, if the library takes longer to load (4.5 introduced 5 new caches) you can disable specific caches. This is done on the EnkaNetworkAPI instance. It is recommended that you read the documentation on EnkaCacheobjects before blocking them.
DO NOT COPY THE SNIPPET INTO YOUR CODE. THIS IS FOR DEMONSTRATION.
final EnkaNetworkAPI api = new EnkaNetworkAPI();
api.setBlockedCaches(EnkaCache.GENSHIN_MATERIALS);
api.build();Global Localization
You can set a localization which is used for when you need to retrieve something from the TextMap. Make sure to call build after you are done with your changes.
api.setDefaultLocalization(GlobalLocalization.GERMAN);Don't use ITALIAN, TURKISH for Honkai: Star Rail and Zenless Zone Zero, these are not supported languages in Honkai: Star Rail and Zenless Zone Zero and will throw you an error if you have it enabled.
User Agent
You can set a user agent which is sent to enka.network when making HTTP requests.
If you ever come across rate limits, then the User Agent is very important so that Algoinde can help increase those limits, however there is a limited queue of requests per minute, so this should not happen. Make sure to call build after you are done with your changes.
api.setUserAgent(...);UI Path
You can also set a custom UI path, which is used when you are requesting png's by an identifier. Make sure to call build after you are done with your changes.
api.setDefaultUIPath(...);The default UI Paths are:
Genshin:
https://enka.network/ui/.Honkai: Star Rail:
https://enka.network/ui/hsr/.Zenless Zone Zero:
https://enka.network
Honkai: Star Rail Support
Yes, as of version 4.0 I have added Honkai: Star Rail Support. If you want to use Honkai: Star Rail in your project, you need to enable it on the api loader. Make sure to call build after you are done with your changes.
I will not make extra documentation on Honkai: Star Rail because it is the same concept as Genshin Impact, if there is any additions that need documentation, I will add it.
api.enableHonkai(true);Zenless Zone Zero Support
Yes, as of version 5.4 I have added Zenless Zone Zero Support. If you want to use Zenless Zone Zero in your project, you need to enable it on the api loader. Make sure to call build after you are done with your changes.
I will not make extra documentation on Zenless Zone Zero because it is the same concept as Genshin Impact and Honkai: Star Rail, if there is any additions that need documentation, I will add it.
api.enableZenless(true);AS OF VERSION 5.5, YOU SHOULD NOT ENABLE THIS!
ZZZ is not finished in the Wrapper (however API exists).
I will be removing this warning if ZZZ is in stable version on the wrapper.
EnkaNetworkBuilder
Some people prefer a factory pattern over a class with multiple voids.
So, you can use EnkaNetworkBuilder for this.
import me.kazury.enkanetworkapi.enka.EnkaNetworkAPI;
import me.kazury.enkanetworkapi.enka.EnkaNetworkBuilder;
import me.kazury.enkanetworkapi.util.GlobalLocalization;
public class Main {
public static void main(String[] args) {
final EnkaNetworkAPI api = new EnkaNetworkBuilder()
.setUserAgent(...)
.setDefaultLocalization(...)
.build();
}
}Retrieving image png's
There are some methods in the API which return an icon identifier.
You will need the identifier if you want to get a png from the identifier.
final String identifier = "UI_AvatarIcon_Furina";
api.getGenshinIcon(identifier); // returns the png from the ui path. 
If you are using the default UI Path then not all images may be available.
The url retrieved by EnkaNetworkAPI#getGenshinIcon will only load if those images were imported and are in use on enka.network.
If an image is not present, you can change the ui path and use a different CDN which has needed images imported.
Rate Limits
When retrieving data (calling any fetch method) an HTTP request will be made to https://enka.network/api/uid/x/ and it is obvious that you cannot do infinite requests in a period.
Though, it is not strictly "x requests per s/min", but it's more of a bucket that fills up, if it goes overboard then you will be pushed towards the rate limit by delaying the requests. If you still manage to go over that bucket, you will be getting a RateLimitedException.
Last updated
Was this helpful?