pokemon
pokelance.ext.pokemon
⚓︎
Pokemon(client)
⚓︎
Bases: BaseExtension
Extension for pokemon related endpoints.
Attributes:
Name | Type | Description |
---|---|---|
cache |
Pokemon
|
The cache for this extension. |
Initializes the extension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
HttpClient
|
The client to use for requests. |
required |
Returns:
Type | Description |
---|---|
BaseExtension
|
The extension. |
Source code in pokelance/ext/_base.py
all_pokemons: t.Optional[t.List[str]]
property
⚓︎
fetch_ability(name)
async
⚓︎
Fetch an ability by name or id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the ability. |
required |
Returns:
Type | Description |
---|---|
Ability
|
The ability if found, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
If the ability was not found. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... ability = await client.pokemon.fetch_ability("stench")
... print(ability.id)
... await client.close()
>>> asyncio.run(main())
1
Source code in pokelance/ext/pokemon.py
fetch_characteristic(id_)
async
⚓︎
Fetch a characteristic by id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_ |
int
|
The id of the characteristic. |
required |
Returns:
Type | Description |
---|---|
Characteristic
|
The characteristic if found, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
If the characteristic was not found. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... characteristic = await client.pokemon.fetch_characteristic(1)
... print(characteristic.gene_modulo)
... await client.close()
>>> asyncio.run(main())
0
Source code in pokelance/ext/pokemon.py
fetch_egg_group(name)
async
⚓︎
Fetch an egg group by name or id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the egg group. |
required |
Returns:
Type | Description |
---|---|
EggGroup
|
The egg group if found, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
If the egg group was not found. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... egg_group = await client.pokemon.fetch_egg_group("monster")
... print(egg_group.id)
... await client.close()
>>> asyncio.run(main())
1
Source code in pokelance/ext/pokemon.py
fetch_gender(name)
async
⚓︎
Fetches a gender model by name or id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the |
required |
Returns:
Type | Description |
---|---|
Gender
|
Gender model if found, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if gender was not found. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... gender = await client.pokemon.fetch_gender(1)
... print(gender.name)
... await client.close()
>>> asyncio.run(main())
female
Source code in pokelance/ext/pokemon.py
fetch_growth_rate(name)
async
⚓︎
Fetches a growth rate model by name or id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the |
required |
Returns:
Type | Description |
---|---|
GrowthRate
|
Growth rate model if found, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if growth rate was not found. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... growth_rate = await client.pokemon.fetch_growth_rate(1)
... print(growth_rate.name)
... await client.close()
>>> asyncio.run(main())
slow
Source code in pokelance/ext/pokemon.py
fetch_location_area_encounter(name)
async
⚓︎
Fetches a location area encounter model by name or id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the |
required |
Returns:
Type | Description |
---|---|
LocationAreaEncounter
|
Location area encounter model if found, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if location area encounter was not found. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... location_area_encounter = await client.pokemon.fetch_location_area_encounter(1)
... print(location_area_encounter.location_area.name)
... await client.close()
>>> asyncio.run(main())
cerulean-city-area
Source code in pokelance/ext/pokemon.py
fetch_nature(name)
async
⚓︎
Fetches a nature model by name or id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the |
required |
Returns:
Type | Description |
---|---|
Nature
|
Nature model if found, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if nature was not found. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... nature = await client.pokemon.fetch_nature(1)
... print(nature.name)
... await client.close()
>>> asyncio.run(main())
hardy
Source code in pokelance/ext/pokemon.py
fetch_pokeathlon_stat(name)
async
⚓︎
Fetches a pokeathlon stat model by name or id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the |
required |
Returns:
Type | Description |
---|---|
PokeathlonStat
|
Pokeathlon stat model if found, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if pokeathlon stat was not found. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... pokeathlon_stat = await client.pokemon.fetch_pokeathlon_stat(1)
... print(pokeathlon_stat.name)
... await client.close()
>>> asyncio.run(main())
speed
Source code in pokelance/ext/pokemon.py
fetch_pokemon(name)
async
⚓︎
Fetches a pokemon model by name or id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the |
required |
Returns:
Type | Description |
---|---|
Pokemon
|
Pokemon model if found, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if pokemon was not found. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... pokemon = await client.pokemon.fetch_pokemon(1)
... print(pokemon.name)
... await client.close()
>>> asyncio.run(main())
bulbasaur
Source code in pokelance/ext/pokemon.py
fetch_pokemon_color(name)
async
⚓︎
Fetches a pokemon color model by name or id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the |
required |
Returns:
Type | Description |
---|---|
PokemonColor
|
Pokemon color model if found, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if pokemon color was not found. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... pokemon_color = await client.pokemon.fetch_pokemon_color(1)
... print(pokemon_color.name)
... await client.close()
>>> asyncio.run(main())
black
Source code in pokelance/ext/pokemon.py
fetch_pokemon_form(name)
async
⚓︎
Fetches a pokemon form model by name or id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the |
required |
Returns:
Type | Description |
---|---|
PokemonForm
|
Pokemon form model if found, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if pokemon form was not found. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... pokemon_form = await client.pokemon.fetch_pokemon_form(1)
... print(pokemon_form.name)
... await client.close()
>>> asyncio.run(main())
bulbasaur
Source code in pokelance/ext/pokemon.py
fetch_pokemon_habitat(name)
async
⚓︎
Fetches a pokemon habitat model by name or id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the |
required |
Returns:
Type | Description |
---|---|
PokemonHabitats
|
Pokemon habitat model if found, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if pokemon habitat was not found. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... pokemon_habitat = await client.pokemon.fetch_pokemon_habitat(1)
... print(pokemon_habitat.name)
... await client.close()
>>> asyncio.run(main())
cave
Source code in pokelance/ext/pokemon.py
fetch_pokemon_shape(name)
async
⚓︎
Fetches a pokemon shape model by name or id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the |
required |
Returns:
Type | Description |
---|---|
PokemonShape
|
Pokemon shape model if found, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if pokemon shape was not found. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... pokemon_shape = await client.pokemon.fetch_pokemon_shape(1)
... print(pokemon_shape.name)
... await client.close()
>>> asyncio.run(main())
ball
Source code in pokelance/ext/pokemon.py
fetch_pokemon_species(name)
async
⚓︎
Fetches a pokemon species model by name or id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the |
required |
Returns:
Type | Description |
---|---|
PokemonSpecies
|
Pokemon species model if found, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if pokemon species was not found. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... pokemon_species = await client.pokemon.fetch_pokemon_species(1)
... print(pokemon_species.name)
... await client.close()
>>> asyncio.run(main())
bulbasaur
Source code in pokelance/ext/pokemon.py
fetch_stat(name)
async
⚓︎
Fetches a stat model by name or id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the |
required |
Returns:
Type | Description |
---|---|
Stat
|
Stat model if found, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if stat was not found. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... stat = await client.pokemon.fetch_stat(1)
... print(stat.name)
... await client.close()
>>> asyncio.run(main())
hp
Source code in pokelance/ext/pokemon.py
fetch_type(name)
async
⚓︎
Fetches a type model by name or id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the |
required |
Returns:
Type | Description |
---|---|
Type
|
Type model if found, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if type was not found. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... type_ = await client.pokemon.fetch_type(1)
... print(type_.name)
... await client.close()
>>> asyncio.run(main())
normal
Source code in pokelance/ext/pokemon.py
get_ability(name)
⚓︎
Get an ability by name or id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the ability. |
required |
Returns:
Type | Description |
---|---|
Optional[Ability]
|
The ability if found, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
If the ability was not found. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> ability = client.pokemon.get_ability("stench")
>>> ability.id
1
Source code in pokelance/ext/pokemon.py
get_characteristic(id_)
⚓︎
Get a characteristic by id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_ |
int
|
The id of the characteristic. |
required |
Returns:
Type | Description |
---|---|
Optional[Characteristic]
|
The characteristic if found, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
If the characteristic was not found. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> characteristic = client.pokemon.get_characteristic(1)
>>> characteristic.gene_modulo
0
Source code in pokelance/ext/pokemon.py
get_egg_group(name)
⚓︎
Get an egg group by name or id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the egg group. |
required |
Returns:
Type | Description |
---|---|
Optional[EggGroup]
|
The egg group if found, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
If the egg group was not found. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> egg_group = client.pokemon.get_egg_group("monster")
>>> egg_group.id
1
Source code in pokelance/ext/pokemon.py
get_gender(name)
⚓︎
Get gender from cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the gender. |
required |
Returns:
Type | Description |
---|---|
Optional[Gender]
|
Gender model if found, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if gender was not found. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> gender = client.pokemon.get_gender(1)
>>> gender.name
'female'
Source code in pokelance/ext/pokemon.py
get_growth_rate(name)
⚓︎
Get growth rate from cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the growth rate. |
required |
Returns:
Type | Description |
---|---|
Optional[GrowthRate]
|
Growth rate model if found, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if growth rate was not found. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> growth_rate = client.pokemon.get_growth_rate(1)
>>> growth_rate.name
'slow'
Source code in pokelance/ext/pokemon.py
get_location_area_encounter(name)
⚓︎
Get location area encounter from cache. It gets areas where a pokemon can be found.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the location area encounter. |
required |
Returns:
Type | Description |
---|---|
Optional[LocationAreaEncounter]
|
Location area encounter model if found, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if location area encounter was not found. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> location_area_encounter = client.pokemon.get_location_area_encounter(1)
>>> location_area_encounter.location_area.name
'cerulean-city-area'
Source code in pokelance/ext/pokemon.py
get_message(case, data)
staticmethod
⚓︎
Gets the error message for a resource not found error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
case |
str
|
The case to use for the error message. |
required |
data |
Set[str]
|
The data to use for the error message. |
required |
Returns:
Type | Description |
---|---|
str
|
The error message. |
Source code in pokelance/ext/_base.py
get_nature(name)
⚓︎
Get nature from cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the nature. |
required |
Returns:
Type | Description |
---|---|
Optional[Nature]
|
Nature model if found, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if nature was not found. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> nature = client.pokemon.get_nature(1)
>>> nature.name
'hardy'
Source code in pokelance/ext/pokemon.py
get_pokeathlon_stat(name)
⚓︎
Get pokeathlon stat from cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the pokeathlon stat. |
required |
Returns:
Type | Description |
---|---|
Optional[PokeathlonStat]
|
Pokeathlon stat model if found, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if pokeathlon stat was not found. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> pokeathlon_stat = client.pokemon.get_pokeathlon_stat(1)
>>> pokeathlon_stat.name
'speed'
Source code in pokelance/ext/pokemon.py
get_pokemon(name)
⚓︎
Get pokemon from cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the pokemon. |
required |
Returns:
Type | Description |
---|---|
Optional[Pokemon]
|
Pokemon model if found, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if pokemon was not found. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> pokemon = client.pokemon.get_pokemon(1)
>>> pokemon.name
'bulbasaur'
Source code in pokelance/ext/pokemon.py
get_pokemon_color(name)
⚓︎
Get pokemon color from cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the pokemon color. |
required |
Returns:
Type | Description |
---|---|
Optional[PokemonColor]
|
Pokemon color model if found, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if pokemon color was not found. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> pokemon_color = client.pokemon.get_pokemon_color(1)
>>> pokemon_color.name
'black'
Source code in pokelance/ext/pokemon.py
get_pokemon_form(name)
⚓︎
Get pokemon form from cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the pokemon form. |
required |
Returns:
Type | Description |
---|---|
Optional[PokemonForm]
|
Pokemon form model if found, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if pokemon form was not found. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> pokemon_form = client.pokemon.get_pokemon_form(1)
>>> pokemon_form.name
'bulbasaur'
Source code in pokelance/ext/pokemon.py
get_pokemon_habitat(name)
⚓︎
Get pokemon habitat from cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the pokemon habitat. |
required |
Returns:
Type | Description |
---|---|
Optional[PokemonHabitats]
|
Pokemon habitat model if found, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if pokemon habitat was not found. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> pokemon_habitat = client.pokemon.get_pokemon_habitat(1)
>>> pokemon_habitat.name
'cave'
Source code in pokelance/ext/pokemon.py
get_pokemon_shape(name)
⚓︎
Get pokemon shape from cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the pokemon shape. |
required |
Returns:
Type | Description |
---|---|
Optional[PokemonShape]
|
Pokemon shape model if found, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if pokemon shape was not found. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> pokemon_shape = client.pokemon.get_pokemon_shape(1)
>>> pokemon_shape.name
'ball'
Source code in pokelance/ext/pokemon.py
get_pokemon_species(name)
⚓︎
Get pokemon species from cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the pokemon species. |
required |
Returns:
Type | Description |
---|---|
Optional[PokemonSpecies]
|
Pokemon species model if found, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if pokemon species was not found. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> pokemon_species = client.pokemon.get_pokemon_species(1)
>>> pokemon_species.name
'bulbasaur'
Source code in pokelance/ext/pokemon.py
get_stat(name)
⚓︎
Get stat from cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the stat. |
required |
Returns:
Type | Description |
---|---|
Optional[Stat]
|
Stat model if found, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if stat was not found. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> stat = client.pokemon.get_stat(1)
>>> stat.name
'hp'
Source code in pokelance/ext/pokemon.py
get_type(name)
⚓︎
Get type from cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the type. |
required |
Returns:
Type | Description |
---|---|
Optional[Type]
|
Type model if found, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
if type was not found. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> type_ = client.pokemon.get_type(1)
>>> type_.name
'normal'
Source code in pokelance/ext/pokemon.py
setup()
async
⚓︎
Sets up the extension.