Skip to content

JoshGuarino/PokeGo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PokeGo

actions Release Go Report Card license

PokeGo is an Golang API wrapper for the PokéAPI v2.

Installation

PokeGo can be installed using the following command:

go get github.com/JoshGuarino/PokeGo

Setup

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.

Main client setup example:
package main

import (
    pokego "github.com/JoshGuarino/PokeGo/pkg"
)

func main() {
    client := pokego.NewClient()
}
Individual resource group setup example:
package main

import (
    "github.com/JoshGuarino/PokeGo/pkg/resources/pokemon"
)

func main() {
    pokemonGroup := pokemon.NewPokemonGroup()
}

Resource Groups

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.

Group Usage Docs PokeAPI Docs
Berries BERRIES.md https://pokeapi.co/docs/v2#berries-section
Contests CONTESTS.md https://pokeapi.co/docs/v2#contests-section
Encounters ENCOUNTERS.md https://pokeapi.co/docs/v2#encounters-section
Evolution EVOLUTION.md https://pokeapi.co/docs/v2#evolution-section
Games GAMES.md https://pokeapi.co/docs/v2#games-section
Items ITEMS.md https://pokeapi.co/docs/v2#items-section
Locations LOCATIONS.md https://pokeapi.co/docs/v2#locations-section
Machines MACHINES.md https://pokeapi.co/docs/v2#machines-section
Moves MOVES.md https://pokeapi.co/docs/v2#moves-section
Pokemon POKEMON.md https://pokeapi.co/docs/v2#pokemon-section
Utility UTILITY.md https://pokeapi.co/docs/v2#utility-section

Pagination

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.

List endpoint pagination examples:
// Main client example returning the first page of 20 results
limit, offset := 20, 0
pokemonList, err := client.Pokemon.GetPokemonList(limit, offset)

// Individual resource group example returning the second page of 20 results
limit, offset := 20, 20 
pokemonList, err := pokemonGroup.GetPokemonList(limit, offset)

Single Resource

Single resource endpoints are used to retrieve a single resource from the PokeAPI. Named resources can be accessed using the name or ID of the resource. Non named resources can be accessed using only the ID of the resource.

Single resource endpoint examples:
// Main client example
pokemon, err := client.Pokemon.GetPokemon("charmander")

// Individual resource group example
pokemon, err := pokemonGroup.GetPokemon("charmander")

Caching

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.

Environment

The environment package manages the API base URL and domain. By default, the environment is set to production. For more information on the environment, see the ENVIRONMENT.md documentation.

Logger

The logger package provides a simple and flexible logging mechanism for your application. It supports various log levels and allows you to track messages. It is a wrapper around the https://github.com/charmbracelet/log library. For more information on the logger, see the LOGGER.md documentation.

Contributing

Contributions are welcome! Please open an issue or submit a pull request if you have any suggestions or improvements. See the CONTRIBUTING.md file for more information.

License

PokeGo is licensed under the BSD 3-Clause License.

About

PokeGo is an Golang API wrapper for the PokéAPI .

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published