iamgio/pokedex-java-api


:snake: Pokémon API for Java, 1st to 7th generation

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.iamgio:pokedex-java-api:1.0.0'
	}
	dependencies {
		implementation("com.github.iamgio:pokedex-java-api:1.0.0")
	}
	<dependency>
	    <groupId>com.github.iamgio</groupId>
	    <artifactId>pokedex-java-api</artifactId>
	    <version>1.0.0</version>
	</dependency>

                            
    libraryDependencies += "com.github.iamgio" % "pokedex-java-api" % "1.0.0"
        
        

                            
    :dependencies [[com.github.iamgio/pokedex-java-api "1.0.0"]]
        
        

Readme


<p align="center"> <img src="https://i.imgur.com/eT8UJl0.png"> </p>

Codacy CodeFactor

Pokédex Java API

pokedex-java-api is the first wrapper for pokeapi.co written in pure Java.

Why should I use PDJ API?

  • [x] Fully documented
  • [x] Everything is treated as an object
  • [x] Mantainable and readable code

Maven

    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>com.github.iAmGio</groupId>
            <artifactId>pokedex-java-api</artifactId>
            <version>VERSION</version>
        </dependency>
    </dependencies>

Gradle

  repositories {
	maven {
	  url 'https://jitpack.io' 
	}
  }
  
  dependencies {
    implementation 'com.github.iAmGio:pokedex-java-api:VERSION'
  }

Manual / JAR

JAR files can be found in the releases tab.

Getting started

To get started, let's try to get the types of Bulbasaur:

public class Main {
    public static void main(String[] args) {
        Pokemon bulbasaur = Pokemon.fromName("bulbasaur");
        Pair<PokemonType, PokemonType> types = bulbasaur.getTypes();
        System.out.println(types.getFirst());
        System.out.println(types.getSecond());
    }
}

This will output:

GRASS
POISON

Every component of the API (such as Pokémons, abilities, etc) can be instantiated by using two static methods: fromName, which takes the name as a string, and fromId, which takes the identifier as a number.

Localized strings

An interesting part of this library is the one which collects strings from various languages, contained inside the lang package.
Every localized string is composed by two fields: name (String) and language (enum Language), and groups of them are stored inside specific lists, such as LocalizedNames or FlavorList (both extend LocalizedNameList). They have a get(Language) method which returns the string in the selected language.

The particular one is FlavorList: a flavor is a localized string assigned within a version (or a version group) of the official game: having a flavor list, you will be able to do something like this:

FlavorList<Version> flavors = ...;
String englishStringFromPearl = flavors.filterVersion(Version.PEARL).get(Language.ENGLISH);

Credits to this project and to pokeapi.co are appreciated.