Data
This will teach you how to retrieve character data and basic properties.
Fetching user data
So, with all this out of the way, I will now explain how to fetch data.
To do this, we simply use the method fetchGenshinUser(id, ...):
api.fetchGenshinUser(722777337, (user) -> {
final GenshinUserInformation info = user.toGenshinUser();
}); GenshinUnconvertedUser is a class with a lot of nullability.
GenshinUserInformationis a class that is being parsed to include nullability
and handle it.
This operation is async and defined code in lambda will be run in some time in the future.
Fetching users characters
You can loop through the characters that this user has in their showcase.
api.fetchGenshinUser(722777337, (user) -> {
final GenshinUserInformation info = user.toGenshinUser();
for (GenshinUserCharacter character : info.getCharacters()) {
}
});info.getCharacters()will be empty if:
User has disabled their showcase
User has put no characters up for showcase.
=> The loop will not run.
Fetching a characters name
To fetch a character name, you can simply get the game data and then invoke getName.
api.fetchGenshinUser(722777337, (user) -> {
final GenshinUserInformation info = user.toGenshinUser();
for (GenshinUserCharacter character : info.getCharacters()) {
System.out.println(character.getGameData().getName());
}
});Last updated
Was this helpful?