Skip to content

Client class

Here's the reference information for the Client class.

You can import the Client class directly from pypokeclient:

from pypokeclient import Client


Synchronous version of the client.

Initializes a Client object.

Parameters:

Name Type Description Default
http_client Client

an httpx.Client used to send request to the API. Please note that hishel.SyncCacheClient is a subclass of httpx.Client so you can pass an instance of that class if you want to cache the responses.

None

__enter__()

Creates the client and deletes all the expired responses from the cache.

Returns:

Name Type Description
Client Client

an instance of the synchronous client.

__exit__(exc_type=None, exc_val=None, exc_tb=None)

Closes the session.

Parameters:

Name Type Description Default
exc_type type[BaseException] | None

exception type. Defaults to None.

None
exc_val BaseException | None

exception value. Defaults to None.

None
exc_tb TracebackType | None

exception traceback. Defaults to None.

None

get_resource_list(endpoint, limit=20, offset=0)

Get a list of resource data.

Parameters:

Name Type Description Default
endpoint str

the endpoint (e.g. "pokemon", "berry", "item").

required
limit int

limits the number of elements to fetch. Defaults to 20.

20
offset int

offset needed to move to next page. Defaults to 0.

0

Returns:

Type Description
NamedAPIResourceList | APIResourceList | None

NamedAPIResourceList | APIResourceList | None: the parsed response from the API if the passed endpoint is among the list of available endpoints.

get_berry(key)

Get data about a berry.

Parameters:

Name Type Description Default
key int | str

id or name of the berry.

required

Returns:

Name Type Description
Berry Berry

the parsed response from the API.

get_berry_firmness(key)

Get data about a berry firmness.

Parameters:

Name Type Description Default
key int | str

id or name of the berry firmness.

required

Returns:

Name Type Description
BerryFirmness BerryFirmness

the parsed response from the API.

get_berry_flavor(key)

Get data about a berry flavor.

Parameters:

Name Type Description Default
key int | str

id or name of the berry flavor.

required

Returns:

Name Type Description
BerryFlavor BerryFlavor

the parsed response from the API.

get_contest_type(key)

Get data about a contest type.

Parameters:

Name Type Description Default
key int | str

id or name of the contest type.

required

Returns:

Name Type Description
ContestType ContestType

the parsed response from the API.

get_contest_effect(key)

Get data about a contest effect.

Parameters:

Name Type Description Default
key int

id of the contest effect.

required

Returns:

Name Type Description
ContestEffect ContestEffect

the parsed response from the API.

get_super_contest_effect(key)

Get data about a super contest effect.

Parameters:

Name Type Description Default
key int

id of the super contest effect.

required

Returns:

Name Type Description
SuperContestEffect SuperContestEffect

the parsed response from the API.

get_encounter_method(key)

Get data about an encounter method.

Parameters:

Name Type Description Default
key int | str

id or name of the encounter method.

required

Returns:

Name Type Description
EncounterMethod EncounterMethod

the parsed response from the API.

get_encounter_condition(key)

Get data about an encounter condition.

Parameters:

Name Type Description Default
key int | str

id or name of the encounter condition.

required

Returns:

Name Type Description
EncounterCondition EncounterCondition

the parsed response from the API.

get_encounter_condition_value(key)

Get data about an encounter condition value.

Parameters:

Name Type Description Default
key int | str

id or name of the encounter condition.

required

Returns:

Name Type Description
EncounterConditionValue EncounterConditionValue

the parsed response from the API.

get_evolution_chain(key)

Get data about an evolution chain.

Parameters:

Name Type Description Default
key int

id of the evolution chain.

required

Returns:

Name Type Description
EvolutionChain EvolutionChain

the parsed response from the API.

get_evolution_trigger(key)

Get data about an evolution trigger.

Parameters:

Name Type Description Default
key int | str

id or name of the evolution trigger.

required

Returns:

Name Type Description
EvolutionTrigger EvolutionTrigger

the parsed response from the API.

get_generation(key)

Get data about a generation.

Parameters:

Name Type Description Default
key int | str

id or name of the generation.

required

Returns:

Name Type Description
Generation Generation

the parsed response from the API.

get_pokedex(key)

Get data about a Pokédex.

Parameters:

Name Type Description Default
key int | str

id or name of the Pokédex.

required

Returns:

Name Type Description
Pokedex Pokedex

the parsed response from the API.

get_version_group(key)

Get data about a version group.

Parameters:

Name Type Description Default
key int | str

id or name of the version group.

required

Returns:

Name Type Description
VersionGroup VersionGroup

the parsed response from the API.

get_version(key)

Get data about a version.

Parameters:

Name Type Description Default
key int | str

id or name of the version.

required

Returns:

Name Type Description
Version Version

the parsed response from the API.

get_item(key)

Get data about an item.

Parameters:

Name Type Description Default
key int | str

id or name of the item.

required

Returns:

Name Type Description
Item Item

the parsed response from the API.

get_item_attribute(key)

Get data about an item attribute.

Parameters:

Name Type Description Default
key int | str

id or name of the item attribute.

required

Returns:

Name Type Description
ItemAttribute ItemAttribute

the parsed response from the API.

get_item_category(key)

Get data about an item category.

Parameters:

Name Type Description Default
key int | str

id or name of the item category.

required

Returns:

Name Type Description
ItemCategory ItemCategory

the parsed response from the API.

get_item_fling_effect(key)

Get data about an item fling effect.

Parameters:

Name Type Description Default
key int | str

id or name of the item fling effect.

required

Returns:

Name Type Description
ItemFlingEffect ItemFlingEffect

the parsed response from the API.

get_item_pocket(key)

Get data about an item pocket.

Parameters:

Name Type Description Default
key int | str

id or name of the item pocket.

required

Returns:

Name Type Description
ItemPocket ItemPocket

the parsed response from the API.

get_location(key)

Get data about a location.

Parameters:

Name Type Description Default
key int | str

id or name of the location.

required

Returns:

Name Type Description
Location Location

the parsed response from the API.

get_location_area(key)

Get data about a location area.

Parameters:

Name Type Description Default
key int | str

id or name of the location area.

required

Returns:

Name Type Description
LocationArea LocationArea

the parsed response from the API.

get_pal_park_area(key)

Get data about a Pal Park area.

Parameters:

Name Type Description Default
key int | str

id or name of the Pal Park area.

required

Returns:

Name Type Description
PalParkArea PalParkArea

the parsed response from the API.

get_regions(key)

Get data about a region.

Parameters:

Name Type Description Default
key int | str

id or name of the region.

required

Returns:

Name Type Description
Region Region

the parsed response from the API.

get_machine(key)

Get data about a machine.

Parameters:

Name Type Description Default
key int

id of the machine.

required

Returns:

Name Type Description
Machine Machine

the parsed response from the API.

get_move(key)

Get data about a move.

Parameters:

Name Type Description Default
key int | str

id or name of the move.

required

Returns:

Name Type Description
Move Move

the parsed response from the API.

get_move_ailment(key)

Get data about a move ailment.

Parameters:

Name Type Description Default
key int | str

id or name of the move ailment.

required

Returns:

Name Type Description
MoveAilment MoveAilment

the parsed response from the API.

get_move_battle_style(key)

Get data about a move battle style.

Parameters:

Name Type Description Default
key int | str

id or name of the move battle style.

required

Returns:

Name Type Description
MoveBattleStyle MoveBattleStyle

the parsed response from the API.

get_move_category(key)

Get data about a move category.

Parameters:

Name Type Description Default
key int | str

id or name of the move category.

required

Returns:

Name Type Description
MoveCategory MoveCategory

the parsed response from the API.

get_damage_class(key)

Get data about a move damage class.

Parameters:

Name Type Description Default
key int | str

id or name of the move damage class.

required

Returns:

Name Type Description
MoveDamageClass MoveDamageClass

the parsed response from the API.

get_move_learn_method(key)

Get data about a move learn method.

Parameters:

Name Type Description Default
key int | str

id or name of the move learn method.

required

Returns:

Name Type Description
MoveLearnMethod MoveLearnMethod

the parsed response from the API.

get_move_target(key)

Get data about a move target.

Parameters:

Name Type Description Default
key int | str

id or name of the move target.

required

Returns:

Name Type Description
MoveTarget MoveTarget

the parsed response from the API.

get_ability(key)

Get data about an ability.

Parameters:

Name Type Description Default
key int | str

id or name of the ability.

required

Returns:

Name Type Description
Ability Ability

the parsed response from the API.

get_characteristic(key)

Get data about a characteristic.

Parameters:

Name Type Description Default
key int

id of the characteristic.

required

Returns:

Name Type Description
Characteristic Characteristic

the parsed response from the API.

get_egg_group(key)

Get data about an egg group.

Parameters:

Name Type Description Default
key int | str

id or name of the egg group.

required

Returns:

Name Type Description
EggGroup EggGroup

the parsed response from the API.

get_gender(key)

Get data about a gender.

Parameters:

Name Type Description Default
key int | str

id or name of the gender.

required

Returns:

Name Type Description
Gender Gender

the parsed response from the API.

get_growth_rate(key)

Get data about a growth rate.

Parameters:

Name Type Description Default
key int | str

id or name of the growth rate.

required

Returns:

Name Type Description
GrowthRate GrowthRate

the parsed response from the API.

get_nature(key)

Get data about a nature.

Parameters:

Name Type Description Default
key int | str

id or name of the nature.

required

Returns:

Name Type Description
Nature Nature

the parsed response from the API.

get_pokeathlon_stat(key)

Get data about a Pokéathlon stat.

Parameters:

Name Type Description Default
key int | str

id or name of the Pokéathlon stat.

required

Returns:

Name Type Description
PokeathlonStat PokeathlonStat

the parsed response from the API.

get_pokemon(key)

Get data about a pokémon.

Parameters:

Name Type Description Default
key int | str

id or name of the pokémon

required

Returns:

Name Type Description
Pokemon Pokemon

the parsed response from the API.

get_pokemon_location_area(key)

Get data about a Pokémon's encounters in a location area.

Parameters:

Name Type Description Default
key int | str

id or name of the Pokémon.

required

Returns:

Name Type Description
LocationAreaEncounter list[LocationAreaEncounter]

the parsed response from the API.

get_pokemon_color(key)

Get data about a Pokémon color.

Parameters:

Name Type Description Default
key int | str

id or name of the Pokémon color.

required

Returns:

Name Type Description
PokemonColor PokemonColor

the parsed response from the API.

get_pokemon_form(key)

Get data about a Pokémon form.

Parameters:

Name Type Description Default
key int | str

id or name of the Pokémon form.

required

Returns:

Name Type Description
PokemonForm PokemonForm

the parsed response from the API.

get_pokemon_habitat(key)

Get data about a Pokémon habitat.

Parameters:

Name Type Description Default
key int | str

id or name of the Pokémon habitat.

required

Returns:

Name Type Description
PokemonHabitat PokemonHabitat

the parsed response from the API.

get_pokemon_shape(key)

Get data about a Pokémon shape.

Parameters:

Name Type Description Default
key int | str

id or name of the Pokémon shape.

required

Returns:

Name Type Description
PokemonShape PokemonShape

the parsed response from the API.

get_pokemon_species(key)

Get data about a Pokémon species.

Parameters:

Name Type Description Default
key int | str

id or name of the Pokémon species.

required

Returns:

Name Type Description
PokemonSpecies PokemonSpecies

the parsed response from the API.

get_stat(key)

Get data about a stat.

Parameters:

Name Type Description Default
key int | str

id or name of the stat.

required

Returns:

Name Type Description
Stat Stat

the parsed response from the API.

get_type(key)

Get data about a type.

Parameters:

Name Type Description Default
key int | str

id or name of the type.

required

Returns:

Name Type Description
Type Type

the parsed response from the API.

get_language(key)

Get infos about a language.

Parameters:

Name Type Description Default
key int | str

id or name of the pokémon

required

Returns:

Name Type Description
Language Language

the parsed response from the API.

get_sprite(url)

Get a sprite from an url.

Parameters:

Name Type Description Default
url str

the url to the sprite.

required

Returns:

Name Type Description
Sprite Sprite

a Sprite object useful to save the image.