Package: pypokedex
PyPokedex is a minimal pokedex library for Python that usesPokeAPIinternally to get Pokemon data. A simple example:RequirementsPython 3.6+InstallingUse:$pipinstallpypokedexto get the latest stable release, or:$pipinstallgit+https://github.com/arnavb/pypokedex.git@masterto get the latest commit on master.DocumentationThis package (pypokedex) only provides one function through the
public API—get. It can be used as follows:importpypokedexpokemon=pypokedex.get(dex=DEX)# DEX must be a valid _national_ pokedex# numberpokemon2=pypokedex.get(name=NAME)# NAME must be a valid name of a pokemonIn addition to the above function, the following classes are provided as part of the public API:Pokemon(returned byget),BaseStats,Ability,Sprites,andMoveNote that these classes shouldn't be initialized through client code; their purpose is mainly for type annotations.Possible ExceptionsATypeErrorwill be raised if the wrong number of arguments or the wrong
type of arguments are passed.APyPokedexHTTPErrorwill be raised with an HTTP code of 404 if the Pokemon
requested is not found.Note: Thenameparameter togetiscase-insensitive.APyPokedexHTTPErrorwill be raised with the proper HTTP code if another type
of HTTP error occurs.APyPokedexErrorwill be raised if arequests exceptionoccurs (with the exception ofrequests.exceptions.HTTPError, handled in the
previous two bullet points).APyPokedexErrorwill be raised if data is missing when parsing the returned
JSON from PokeAPI (usually this indicates an API change).Once a validpypokedex.pokemon.Pokemonobject is returned, the following
members are provided for its consumption:Member Variablesdex(int): Contains thenationalPokedex number of the current Pokemon.name(str): Contains the name of the current Pokemon.height(int): Contains the height of the current Pokemon in decimeters (seeveekun/pokedex#249).weight(int): Contains the weight of the current Pokemon in hectograms (seeveekun/pokedex#249).base_experience(intt): Contains the base experience yield of the current Pokemon.types(List[str]): Contains a list of strings with the name of the current
Pokemon's types.abilities(List[Ability]): Contains a list of named tuples calledAbility.
EachAbilityhas the following members:name(str): The name of the current ability.is_hidden(bool): Whether the current ability is a hidden ability or not.base_stats(BaseStats): Contains a named tuple with the current
Pokemon's base stats stored as follows (allints):hp: The base HP of the current Pokemon.attack: The base attack of the current Pokemon.defense: The base defense of the current Pokemon.sp_atk: The base special attack of the current Pokemon.sp_def: The base special defense of the current Pokemon.speed: The base speed of the current Pokemon.moves(DefaultDict[str, List[Move]]): Contains a dictionary of game names
(according to PokeAPI) to a list of named tuples calledMoverepresenting the
moves the current Pokemon learns in the respective game. TheMovenamed tuple
contains the following members:name(str): The name of the current move.learn_method(str): The method the current Pokemon uses to learn the
current move (according to PokeAPI).level(int): The level the current Pokemon learns the current move iflearn_methodislevel-up,Noneotherwise.sprites(Sprites): Contains two dictionaries,frontandbackrepresenting the respective sprites of the current Pokemon. The keys in the dictionary arePokeapi sprite keyswithout the direction prefix (e.gback_defaultis justdefaultin thebackdictionary).other_sprites(Dict[str, Sprites]): Contains a mapping of sprite groups to sprites (sprites are stored in the same way as thespritesinstance variable.version_sprites(Dict[str, Dict[str, Sprites]]): Contains a mapping of generations to games to sprites. Note that like the API itself, keys are included for all generations and games, despite the fact that those Pokemon may not exist in said generation or game. e.gpypokedex.get(name='garchomp')would include keys for generation 1 through 3, even though it was introduced in generation 4.Member Functionsdef exists_in(self, game: str) -> bool: Method to check whether the current
Pokemon exists in a specific game.def learns(self, move_name: str, game: str) -> bool: Method to check
whether the current Pokemon learns a specific move in a specific game.def get_descriptions(self, language="en") -> Dict[str, str]: Method to returns all the descriptions of the current Pokemon for the specified language (en by default).Note: This function only returns the descriptions as a dictionary. It doesn't store them anywhere on the Pokemon object. This was done since the descriptions are fetched from a separate API endpoint.def __str__(self) -> str: Method to get a string represenation of the
current Pokemon. This string is of the form:Pokemon(dex={self.dex}, name='{self.name}').__eq__, __lt__, __gt__, __le__, __ge__: Methods that implement various
comparison operators for Pokemon objects in terms of their Pokedex number.Possible Exceptionslearnswill raise aPyPokedexErrorif the current Pokemon does not exist
in the game specified.LicenseThis library is licensed under theMIT License.Dependency LicensesThis library depends onrequests, which is licensed under theApache 2.0 License.