PokeGo is an Golang API wrapper for the PokéAPI v2.
PokeGo can be installed using the following command:
go get github.com/JoshGuarino/PokeGo
There are two options for using PokeGo. You can either use the main client or create individual resource groups seperately. The main client will initialize all resource groups for you. If you choose to use individual resource groups, you will need to initialize each group separately.
import (
pokego "github.com/JoshGuarino/PokeGo/pkg"
)
client := pokego.NewClient()
import (
"github.com/JoshGuarino/PokeGo/pkg/resources/pokemon"
)
pokemonGroup := pokemon.NewPokemonGroup()
Below is a list of all the resource groups available in PokeGo. Each resource group has a set of methods that can be used to interact with the PokeAPI.
PokeGo supports pagination for list endpoints. The GetPokemonList()
method is an example of a list endpoint that supports pagination.
The method takes two arguments, limit
and offset
. The limit
argument is the number of results to return and the offset
argument
is the number of results to skip. Both arugments are required as Golang does not support default arguments.
// Main client example returning the first page of 20 results
pokemonList, err := client.Pokemon.GetPokemonList(20, 0)
// Individual resource group example returning the second page of 20 results
pokemonList, err := pokemonGroup.GetPokemonList(20, 20)
PokeGo uses a simple in-memory cache to store API responses. This is to reduce the number of requests made to the PokeAPI. The cache is set to expire after 24 hours by default, as resources in the PokeAPI are mostly static. You are able to disable the cache or change the expiration time of a cached resource. I would reccommend against disabling it as it will result in a large number of requests to the PokeAPI and may result in rate limiting. For more information on the cache, see the CACHE.md documentation.
PokeGo is licensed under the BSD 3-Clause License.