PokeAPI

Crystal wrapper library for PokéAPI.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      pokeapi:
        github: henrikac/pokeapi
  2. Run shards install

Usage

Get a list of resources

To get a list of resources from any of the endpoints specified below use

.resource(endpoint : String, limit : UInt32 = 20, offset : UInt32 = 0)

require "pokeapi"

# returns a list of the first 20 pokémons
pokemons = PokeAPI.resource("pokemon")

# returns a list of 8 pokémons starting from #90 (if possible)
pokemons = PokeAPI.resource("pokemon", limit: 8, offset: 90)

Get a single item

Each of the endpoints has a corresponding method that can be used to get data from that specific endpoint, e.g.

/pokemon/{id or name}/
require "pokeapi"

pokemon_id = PokeAPI.pokemon(25) # => returns pokémon with id == 25
pokemon_name = PokeAPI.pokemon("eevee") # => returns pokémon with name eevee
/growth-rate/{id or name}/
require "pokeapi"

growth_rate = PokeAPI.growth_rate(2) # => returns growth-rate with id == 2

Endpoints

Berries

Contests

Encounters

Evolution

Games

Items

Locations

Machines

Moves

Pokémon

Contributing

  1. Fork it (https://github.com/henrikac/pokeapi/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors