PokeAPI / pokebase

Python 3 wrapper for Pokéapi v2
BSD 3-Clause "New" or "Revised" License
286 stars 53 forks source link

pokemon-types not being answered correctly #43

Open dns-ls opened 1 year ago

dns-ls commented 1 year ago

Tried on both Windows and Linux, when requesting for pokemons type, the API always answers something like this (instead of "fire"):

>>> import pokebase as pb
>>> print(pb.pokemon('charmander').types)
[<pokebase.interface.APIMetadata object at 0x00000212A9AE6710>]
khancerberus commented 1 year ago

Try with:

for type in pb.pokemon('charmander').types:
    print(type.name)

Why? 'types' returns a type list, and type object is an APIMetadata object. According to the PokeAPI, a type request can contains:

{
  "id": 5,
  "name": "ground",
  ... more json data
}