Pokemon
pokemon
¶
Pokemon
¶
Bases: AsyncBaseExtension[Pokemon]
Extension for pokemon related endpoints.
Source code in pokelance/ext/_base.py
get_ability
¶
Gets a ability from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Ability | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
def get_ability(self, name: str | int) -> models.Ability | None:
"""Gets a ability from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Ability | None
The cached model or None.
Examples
--------
```python
ability = client.pokemon.get_ability("stench")
if ability:
print(ability)
```"""
route = Endpoint.get_ability(name)
self._validate_resource(self._cache_group.ability, name, route)
return self._cache_group.ability.get(route, None)
fetch_ability
async
¶
Fetches a ability from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Ability
|
The fetched model. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
async def fetch_ability(self, name: str | int) -> models.Ability:
"""Fetches a ability from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Ability
The fetched model.
Examples
--------
```python
ability = await client.pokemon.fetch_ability("stench")
print(ability)
```"""
route = Endpoint.get_ability(name)
self._validate_resource(self._cache_group.ability, name, route)
data = await self._client.request(route)
return self._cache_group.ability.setdefault(route, self._cache_group.ability.from_payload(data))
get_characteristic
¶
get_characteristic(id: int) -> Characteristic | None
Gets a characteristic from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
The resource id. |
required |
Returns:
| Type | Description |
|---|---|
Characteristic | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
def get_characteristic(self, id: int) -> models.Characteristic | None:
"""Gets a characteristic from the cache.
Parameters
----------
id : int
The resource id.
Returns
-------
models.Characteristic | None
The cached model or None.
Examples
--------
```python
characteristic = client.pokemon.get_characteristic(1)
if characteristic:
print(characteristic)
```"""
route = Endpoint.get_characteristic(id)
self._validate_resource(self._cache_group.characteristic, id, route)
return self._cache_group.characteristic.get(route, None)
fetch_characteristic
async
¶
fetch_characteristic(id: int) -> Characteristic
Fetches a characteristic from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
The resource id. |
required |
Returns:
| Type | Description |
|---|---|
Characteristic
|
The fetched model. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
async def fetch_characteristic(self, id: int) -> models.Characteristic:
"""Fetches a characteristic from the API.
Parameters
----------
id : int
The resource id.
Returns
-------
models.Characteristic
The fetched model.
Examples
--------
```python
characteristic = await client.pokemon.fetch_characteristic(1)
print(characteristic)
```"""
route = Endpoint.get_characteristic(id)
self._validate_resource(self._cache_group.characteristic, id, route)
data = await self._client.request(route)
return self._cache_group.characteristic.setdefault(route, self._cache_group.characteristic.from_payload(data))
get_egg_group
¶
Gets a egg group from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
EggGroup | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
def get_egg_group(self, name: str | int) -> models.EggGroup | None:
"""Gets a egg group from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.EggGroup | None
The cached model or None.
Examples
--------
```python
group = client.pokemon.get_egg_group("monster")
if group:
print(group)
```"""
route = Endpoint.get_egg_group(name)
self._validate_resource(self._cache_group.egg_group, name, route)
return self._cache_group.egg_group.get(route, None)
fetch_egg_group
async
¶
Fetches a egg group from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
EggGroup
|
The fetched model. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
async def fetch_egg_group(self, name: str | int) -> models.EggGroup:
"""Fetches a egg group from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.EggGroup
The fetched model.
Examples
--------
```python
group = await client.pokemon.fetch_egg_group("monster")
print(group)
```"""
route = Endpoint.get_egg_group(name)
self._validate_resource(self._cache_group.egg_group, name, route)
data = await self._client.request(route)
return self._cache_group.egg_group.setdefault(route, self._cache_group.egg_group.from_payload(data))
get_gender
¶
Gets a gender from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Gender | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
def get_gender(self, name: str | int) -> models.Gender | None:
"""Gets a gender from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Gender | None
The cached model or None.
Examples
--------
```python
gender = client.pokemon.get_gender("female")
if gender:
print(gender)
```"""
route = Endpoint.get_gender(name)
self._validate_resource(self._cache_group.gender, name, route)
return self._cache_group.gender.get(route, None)
fetch_gender
async
¶
Fetches a gender from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Gender
|
The fetched model. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
async def fetch_gender(self, name: str | int) -> models.Gender:
"""Fetches a gender from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Gender
The fetched model.
Examples
--------
```python
gender = await client.pokemon.fetch_gender("female")
print(gender)
```"""
route = Endpoint.get_gender(name)
self._validate_resource(self._cache_group.gender, name, route)
data = await self._client.request(route)
return self._cache_group.gender.setdefault(route, self._cache_group.gender.from_payload(data))
get_growth_rate
¶
get_growth_rate(name: str | int) -> GrowthRate | None
Gets a growth rate from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
GrowthRate | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
def get_growth_rate(self, name: str | int) -> models.GrowthRate | None:
"""Gets a growth rate from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.GrowthRate | None
The cached model or None.
Examples
--------
```python
rate = client.pokemon.get_growth_rate("slow")
if rate:
print(rate)
```"""
route = Endpoint.get_growth_rate(name)
self._validate_resource(self._cache_group.growth_rate, name, route)
return self._cache_group.growth_rate.get(route, None)
fetch_growth_rate
async
¶
fetch_growth_rate(name: str | int) -> GrowthRate
Fetches a growth rate from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
GrowthRate
|
The fetched model. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
async def fetch_growth_rate(self, name: str | int) -> models.GrowthRate:
"""Fetches a growth rate from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.GrowthRate
The fetched model.
Examples
--------
```python
rate = await client.pokemon.fetch_growth_rate("slow")
print(rate)
```"""
route = Endpoint.get_growth_rate(name)
self._validate_resource(self._cache_group.growth_rate, name, route)
data = await self._client.request(route)
return self._cache_group.growth_rate.setdefault(route, self._cache_group.growth_rate.from_payload(data))
get_nature
¶
Gets a nature from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Nature | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
def get_nature(self, name: str | int) -> models.Nature | None:
"""Gets a nature from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Nature | None
The cached model or None.
Examples
--------
```python
nature = client.pokemon.get_nature("hardy")
if nature:
print(nature)
```"""
route = Endpoint.get_nature(name)
self._validate_resource(self._cache_group.nature, name, route)
return self._cache_group.nature.get(route, None)
fetch_nature
async
¶
Fetches a nature from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Nature
|
The fetched model. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
async def fetch_nature(self, name: str | int) -> models.Nature:
"""Fetches a nature from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Nature
The fetched model.
Examples
--------
```python
nature = await client.pokemon.fetch_nature("hardy")
print(nature)
```"""
route = Endpoint.get_nature(name)
self._validate_resource(self._cache_group.nature, name, route)
data = await self._client.request(route)
return self._cache_group.nature.setdefault(route, self._cache_group.nature.from_payload(data))
get_pokeathlon_stat
¶
get_pokeathlon_stat(
name: str | int,
) -> PokeathlonStat | None
Gets a pokeathlon stat from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
PokeathlonStat | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
def get_pokeathlon_stat(self, name: str | int) -> models.PokeathlonStat | None:
"""Gets a pokeathlon stat from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.PokeathlonStat | None
The cached model or None.
Examples
--------
```python
stat = client.pokemon.get_pokeathlon_stat("speed")
if stat:
print(stat)
```"""
route = Endpoint.get_pokeathlon_stat(name)
self._validate_resource(self._cache_group.pokeathlon_stat, name, route)
return self._cache_group.pokeathlon_stat.get(route, None)
fetch_pokeathlon_stat
async
¶
fetch_pokeathlon_stat(name: str | int) -> PokeathlonStat
Fetches a pokeathlon stat from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
PokeathlonStat
|
The fetched model. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
async def fetch_pokeathlon_stat(self, name: str | int) -> models.PokeathlonStat:
"""Fetches a pokeathlon stat from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.PokeathlonStat
The fetched model.
Examples
--------
```python
stat = await client.pokemon.fetch_pokeathlon_stat("speed")
print(stat)
```"""
route = Endpoint.get_pokeathlon_stat(name)
self._validate_resource(self._cache_group.pokeathlon_stat, name, route)
data = await self._client.request(route)
return self._cache_group.pokeathlon_stat.setdefault(route, self._cache_group.pokeathlon_stat.from_payload(data))
get_pokemon
¶
Gets a pokemon from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Pokemon | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
def get_pokemon(self, name: str | int) -> models.Pokemon | None:
"""Gets a pokemon from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Pokemon | None
The cached model or None.
Examples
--------
```python
pokemon = client.pokemon.get_pokemon("pikachu")
if pokemon:
print(pokemon)
```"""
route = Endpoint.get_pokemon(name)
self._validate_resource(self._cache_group.pokemon, name, route)
return self._cache_group.pokemon.get(route, None)
fetch_pokemon
async
¶
Fetches a pokemon from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Pokemon
|
The fetched model. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
async def fetch_pokemon(self, name: str | int) -> models.Pokemon:
"""Fetches a pokemon from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Pokemon
The fetched model.
Examples
--------
```python
pokemon = await client.pokemon.fetch_pokemon("pikachu")
print(pokemon)
```"""
route = Endpoint.get_pokemon(name)
self._validate_resource(self._cache_group.pokemon, name, route)
data = await self._client.request(route)
return self._cache_group.pokemon.setdefault(route, self._cache_group.pokemon.from_payload(data))
get_pokemon_color
¶
get_pokemon_color(name: str | int) -> PokemonColor | None
Gets a pokemon color from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
PokemonColor | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
def get_pokemon_color(self, name: str | int) -> models.PokemonColor | None:
"""Gets a pokemon color from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.PokemonColor | None
The cached model or None.
Examples
--------
```python
color = client.pokemon.get_pokemon_color("black")
if color:
print(color)
```"""
route = Endpoint.get_pokemon_color(name)
self._validate_resource(self._cache_group.pokemon_color, name, route)
return self._cache_group.pokemon_color.get(route, None)
fetch_pokemon_color
async
¶
fetch_pokemon_color(name: str | int) -> PokemonColor
Fetches a pokemon color from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
PokemonColor
|
The fetched model. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
async def fetch_pokemon_color(self, name: str | int) -> models.PokemonColor:
"""Fetches a pokemon color from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.PokemonColor
The fetched model.
Examples
--------
```python
color = await client.pokemon.fetch_pokemon_color("black")
print(color)
```"""
route = Endpoint.get_pokemon_color(name)
self._validate_resource(self._cache_group.pokemon_color, name, route)
data = await self._client.request(route)
return self._cache_group.pokemon_color.setdefault(route, self._cache_group.pokemon_color.from_payload(data))
get_pokemon_form
¶
get_pokemon_form(name: str | int) -> PokemonForm | None
Gets a pokemon form from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
PokemonForm | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
def get_pokemon_form(self, name: str | int) -> models.PokemonForm | None:
"""Gets a pokemon form from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.PokemonForm | None
The cached model or None.
Examples
--------
```python
form = client.pokemon.get_pokemon_form("pikachu")
if form:
print(form)
```"""
route = Endpoint.get_pokemon_form(name)
self._validate_resource(self._cache_group.pokemon_form, name, route)
return self._cache_group.pokemon_form.get(route, None)
fetch_pokemon_form
async
¶
fetch_pokemon_form(name: str | int) -> PokemonForm
Fetches a pokemon form from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
PokemonForm
|
The fetched model. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
async def fetch_pokemon_form(self, name: str | int) -> models.PokemonForm:
"""Fetches a pokemon form from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.PokemonForm
The fetched model.
Examples
--------
```python
form = await client.pokemon.fetch_pokemon_form("pikachu")
print(form)
```"""
route = Endpoint.get_pokemon_form(name)
self._validate_resource(self._cache_group.pokemon_form, name, route)
data = await self._client.request(route)
return self._cache_group.pokemon_form.setdefault(route, self._cache_group.pokemon_form.from_payload(data))
get_pokemon_habitat
¶
get_pokemon_habitat(
name: str | int,
) -> PokemonHabitats | None
Gets a pokemon habitat from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
PokemonHabitats | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
def get_pokemon_habitat(self, name: str | int) -> models.PokemonHabitats | None:
"""Gets a pokemon habitat from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.PokemonHabitats | None
The cached model or None.
Examples
--------
```python
habitat = client.pokemon.get_pokemon_habitat("cave")
if habitat:
print(habitat)
```"""
route = Endpoint.get_pokemon_habitat(name)
self._validate_resource(self._cache_group.pokemon_habitat, name, route)
return self._cache_group.pokemon_habitat.get(route, None)
fetch_pokemon_habitat
async
¶
fetch_pokemon_habitat(name: str | int) -> PokemonHabitats
Fetches a pokemon habitat from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
PokemonHabitats
|
The fetched model. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
async def fetch_pokemon_habitat(self, name: str | int) -> models.PokemonHabitats:
"""Fetches a pokemon habitat from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.PokemonHabitats
The fetched model.
Examples
--------
```python
habitat = await client.pokemon.fetch_pokemon_habitat("cave")
print(habitat)
```"""
route = Endpoint.get_pokemon_habitat(name)
self._validate_resource(self._cache_group.pokemon_habitat, name, route)
data = await self._client.request(route)
return self._cache_group.pokemon_habitat.setdefault(route, self._cache_group.pokemon_habitat.from_payload(data))
get_pokemon_shape
¶
get_pokemon_shape(name: str | int) -> PokemonShape | None
Gets a pokemon shape from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
PokemonShape | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
def get_pokemon_shape(self, name: str | int) -> models.PokemonShape | None:
"""Gets a pokemon shape from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.PokemonShape | None
The cached model or None.
Examples
--------
```python
shape = client.pokemon.get_pokemon_shape("ball")
if shape:
print(shape)
```"""
route = Endpoint.get_pokemon_shape(name)
self._validate_resource(self._cache_group.pokemon_shape, name, route)
return self._cache_group.pokemon_shape.get(route, None)
fetch_pokemon_shape
async
¶
fetch_pokemon_shape(name: str | int) -> PokemonShape
Fetches a pokemon shape from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
PokemonShape
|
The fetched model. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
async def fetch_pokemon_shape(self, name: str | int) -> models.PokemonShape:
"""Fetches a pokemon shape from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.PokemonShape
The fetched model.
Examples
--------
```python
shape = await client.pokemon.fetch_pokemon_shape("ball")
print(shape)
```"""
route = Endpoint.get_pokemon_shape(name)
self._validate_resource(self._cache_group.pokemon_shape, name, route)
data = await self._client.request(route)
return self._cache_group.pokemon_shape.setdefault(route, self._cache_group.pokemon_shape.from_payload(data))
get_pokemon_species
¶
get_pokemon_species(
name: str | int,
) -> PokemonSpecies | None
Gets a pokemon species from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
PokemonSpecies | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
def get_pokemon_species(self, name: str | int) -> models.PokemonSpecies | None:
"""Gets a pokemon species from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.PokemonSpecies | None
The cached model or None.
Examples
--------
```python
species = client.pokemon.get_pokemon_species("pikachu")
if species:
print(species)
```"""
route = Endpoint.get_pokemon_species(name)
self._validate_resource(self._cache_group.pokemon_species, name, route)
return self._cache_group.pokemon_species.get(route, None)
fetch_pokemon_species
async
¶
fetch_pokemon_species(name: str | int) -> PokemonSpecies
Fetches a pokemon species from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
PokemonSpecies
|
The fetched model. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
async def fetch_pokemon_species(self, name: str | int) -> models.PokemonSpecies:
"""Fetches a pokemon species from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.PokemonSpecies
The fetched model.
Examples
--------
```python
species = await client.pokemon.fetch_pokemon_species("pikachu")
print(species)
```"""
route = Endpoint.get_pokemon_species(name)
self._validate_resource(self._cache_group.pokemon_species, name, route)
data = await self._client.request(route)
return self._cache_group.pokemon_species.setdefault(route, self._cache_group.pokemon_species.from_payload(data))
get_stat
¶
Gets a stat from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Stat | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
def get_stat(self, name: str | int) -> models.Stat | None:
"""Gets a stat from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Stat | None
The cached model or None.
Examples
--------
```python
stat = client.pokemon.get_stat("hp")
if stat:
print(stat)
```"""
route = Endpoint.get_stat(name)
self._validate_resource(self._cache_group.stat, name, route)
return self._cache_group.stat.get(route, None)
fetch_stat
async
¶
Fetches a stat from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Stat
|
The fetched model. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
async def fetch_stat(self, name: str | int) -> models.Stat:
"""Fetches a stat from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Stat
The fetched model.
Examples
--------
```python
stat = await client.pokemon.fetch_stat("hp")
print(stat)
```"""
route = Endpoint.get_stat(name)
self._validate_resource(self._cache_group.stat, name, route)
data = await self._client.request(route)
return self._cache_group.stat.setdefault(route, self._cache_group.stat.from_payload(data))
get_type
¶
Gets a type from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Type | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
def get_type(self, name: str | int) -> models.Type | None:
"""Gets a type from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Type | None
The cached model or None.
Examples
--------
```python
type_data = client.pokemon.get_type("normal")
if type_data:
print(type_data)
```"""
route = Endpoint.get_type(name)
self._validate_resource(self._cache_group.type, name, route)
return self._cache_group.type.get(route, None)
fetch_type
async
¶
Fetches a type from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Type
|
The fetched model. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
async def fetch_type(self, name: str | int) -> models.Type:
"""Fetches a type from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Type
The fetched model.
Examples
--------
```python
type_data = await client.pokemon.fetch_type("normal")
print(type_data)
```"""
route = Endpoint.get_type(name)
self._validate_resource(self._cache_group.type, name, route)
data = await self._client.request(route)
return self._cache_group.type.setdefault(route, self._cache_group.type.from_payload(data))
get_location_area_encounter
¶
get_location_area_encounter(
name: str | int,
) -> list[LocationAreaEncounter] | None
Gets a location area encounter from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
list[LocationAreaEncounter] | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
def get_location_area_encounter(self, name: str | int) -> list[models.LocationAreaEncounter] | None:
"""Gets a location area encounter from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
list[models.LocationAreaEncounter] | None
The cached model or None.
Examples
--------
```python
encounter = client.pokemon.get_location_area_encounter("pikachu")
if encounter:
print(encounter)
```"""
route = Endpoint.get_location_area_encounter(name)
self._validate_resource(self._cache_group.location_area_encounter, name, route)
return self._cache_group.location_area_encounter.get(route, None)
fetch_location_area_encounter
async
¶
fetch_location_area_encounter(
name: str | int,
) -> list[LocationAreaEncounter]
Fetches a location area encounter from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
list[LocationAreaEncounter]
|
The fetched model. |
Examples:
Source code in pokelance/ext/_async/pokemon.py
async def fetch_location_area_encounter(self, name: str | int) -> list[models.LocationAreaEncounter]:
"""Fetches a location area encounter from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
list[models.LocationAreaEncounter]
The fetched model.
Examples
--------
```python
encounter = await client.pokemon.fetch_location_area_encounter("pikachu")
print(encounter)
```"""
route = Endpoint.get_location_area_encounter(name)
self._validate_resource(self._cache_group.location_area_encounter, name, route)
data = await self._client.request(route)
return self._cache_group.location_area_encounter.setdefault(
route, self._cache_group.location_area_encounter.from_payload(data)
)
setup
¶
setup(lance: PokeLanceAsyncClient) -> None