Skip to content

AsyncClient class

Here's the reference information for the AsyncClient class.

You can import the AsyncClient class directly from pypokeclient:

from pypokeclient import AsyncClient


AsyncClient

AsyncClient(http_client: httpx.AsyncClient)

Asynchronous version of the client.

Parameters:

Name Type Description Default
http_client httpx.AsyncClient

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

required
Source code in pypokeclient/async_client.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
def __init__(self, http_client: httpx.AsyncClient) -> None:
    """Initializes an `AsyncClient` object.

    Args:
        http_client (httpx.AsyncClient): an `httpx.AsyncClient` used to send request to the API. Please note that
            `hishel.AsyncCacheClient` is a subclass of `httpx.AsyncClient` so you can pass an instance of that
            class if you want to cache the responses.
    """
    if http_client is None:
        self._http_client = httpx.AsyncClient(base_url="https://pokeapi.co/api/v2/")
    else:
        self._http_client = http_client
        if self._http_client.base_url == "":
            self._http_client.base_url = "https://pokeapi.co/api/v2/"

    if isinstance(self._http_client, AsyncCacheClient):
        logger.info(
            f"The asynchronous client is ready and using the cache at "
            f"'{self._http_client._transport.storage.database_path}'."
        )
    else:
        logger.info("The asynchronous client is ready without using any cache.")

_http_client

_http_client = httpx.AsyncClient(base_url='https://pokeapi.co/api/v2/')

__aenter__

__aenter__() -> AsyncClient

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

Returns:

Name Type Description
AsyncClient AsyncClient

an instance of the asynchronous client.

Source code in pypokeclient/async_client.py
45
46
47
48
49
50
51
async def __aenter__(self) -> "AsyncClient":
    """Creates the client and deletes all the expired responses from the cache.

    Returns:
        AsyncClient: an instance of the asynchronous client.
    """
    return self

__aexit__

__aexit__(exc_type: type[BaseException] | None = None, exc_val: BaseException | None = None, exc_tb: TracebackType | None = None) -> 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
Source code in pypokeclient/async_client.py
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
async def __aexit__(
    self,
    exc_type: type[BaseException] | None = None,
    exc_val: BaseException | None = None,
    exc_tb: TracebackType | None = None,
) -> None:
    """Closes the session.

    Args:
        exc_type (type[BaseException] | None): exception type. Defaults to None.
        exc_val (BaseException | None): exception value. Defaults to None.
        exc_tb (TracebackType | None): exception traceback. Defaults to None.
    """
    del exc_type, exc_val, exc_tb
    await self._http_client.aclose()
    logger.info("Closed session for the asynchronous client.")

_api_request

_api_request(url: str) -> httpx.Response

Sends an API request.

Parameters:

Name Type Description Default
url str

the url to which the request will be sent.

required

Returns:

Type Description
httpx.Response

httpx.Response: the non-parsed response from the API.

Source code in pypokeclient/async_client.py
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
async def _api_request(self, url: str) -> httpx.Response:
    """Sends an API request.

    Args:
        url (str): the url to which the request will be sent.

    Returns:
        httpx.Response: the non-parsed response from the API.
    """
    try:
        response = await self._http_client.get(url)
        response.raise_for_status()
    except httpx.HTTPError as e:
        raise e

    log_msg = f"[{response.status_code}] Request to {response.url}."
    if response.extensions.get("hishel_from_cache", False):
        log_msg = f"[{response.status_code}] Cached request to {response.url}."

    logger.info(log_msg)
    return response

_get_resource

_get_resource(endpoint: str, key: int | str, model: type[T]) -> T
Source code in pypokeclient/async_client.py
95
96
97
async def _get_resource[T](self, endpoint: str, key: int | str, model: type[T]) -> T:
    response = await self._api_request(f"{endpoint}/{key}")
    return model(**response.json())

_get_resources

_get_resources(endpoint: str, key: int | str, model: type[T]) -> list[T]
Source code in pypokeclient/async_client.py
 99
100
101
async def _get_resources[T](self, endpoint: str, key: int | str, model: type[T]) -> list[T]:
    response = await self._api_request(f"{endpoint}/{key}")
    return [model(**data) for data in response.json()]

get_resource_list

get_resource_list(endpoint: str, limit: int = 20, offset: int = 0) -> _api.NamedAPIResourceList | _api.APIResourceList | None

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
_api.NamedAPIResourceList | _api.APIResourceList | None

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

Source code in pypokeclient/async_client.py
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
@validate_call
async def get_resource_list(
    self, endpoint: str, limit: int = 20, offset: int = 0
) -> _api.NamedAPIResourceList | _api.APIResourceList | None:
    """Get a list of resource data.

    Args:
        endpoint (str): the endpoint (e.g. "pokemon", "berry", "item").
        limit (int, optional): limits the number of elements to fetch. Defaults to 20.
        offset (int, optional): offset needed to move to next page. Defaults to 0.

    Returns:
        NamedAPIResourceList | APIResourceList | None: the parsed response from the API if the passed endpoint is
            among the list of available endpoints.
    """
    if endpoint in UNNAMED_ENDPOINTS:
        return await self._get_resource(endpoint, f"?limit={limit}&offset={offset}", _api.APIResourceList)
    elif endpoint in NAMED_ENDPOINTS:
        return await self._get_resource(endpoint, f"?limit={limit}&offset={offset}", _api.NamedAPIResourceList)
    else:
        logger.error(f"{endpoint} is not among the list of available endpoints.")
        return None

get_berry

get_berry(key: int | str) -> _api.Berry

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 _api.Berry

the parsed response from the API.

Source code in pypokeclient/async_client.py
132
133
134
135
136
137
138
139
140
141
142
@validate_call
async def get_berry(self, key: int | str) -> _api.Berry:
    """Get data about a berry.

    Args:
        key (int | str): id or name of the berry.

    Returns:
        Berry: the parsed response from the API.
    """
    return await self._get_resource("berry", key, _api.Berry)

get_berry_firmness

get_berry_firmness(key: int | str) -> _api.BerryFirmness

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 _api.BerryFirmness

the parsed response from the API.

Source code in pypokeclient/async_client.py
144
145
146
147
148
149
150
151
152
153
154
@validate_call
async def get_berry_firmness(self, key: int | str) -> _api.BerryFirmness:
    """Get data about a berry firmness.

    Args:
        key (int | str): id or name of the berry firmness.

    Returns:
        BerryFirmness: the parsed response from the API.
    """
    return await self._get_resource("berry-firmness", key, _api.BerryFirmness)

get_berry_flavor

get_berry_flavor(key: int | str) -> _api.BerryFlavor

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 _api.BerryFlavor

the parsed response from the API.

Source code in pypokeclient/async_client.py
156
157
158
159
160
161
162
163
164
165
166
@validate_call
async def get_berry_flavor(self, key: int | str) -> _api.BerryFlavor:
    """Get data about a berry flavor.

    Args:
        key (int | str): id or name of the berry flavor.

    Returns:
        BerryFlavor: the parsed response from the API.
    """
    return await self._get_resource("berry-flavor", key, _api.BerryFlavor)

get_contest_type

get_contest_type(key: int | str) -> _api.ContestType

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 _api.ContestType

the parsed response from the API.

Source code in pypokeclient/async_client.py
171
172
173
174
175
176
177
178
179
180
181
@validate_call
async def get_contest_type(self, key: int | str) -> _api.ContestType:
    """Get data about a contest type.

    Args:
        key (int | str): id or name of the contest type.

    Returns:
        ContestType: the parsed response from the API.
    """
    return await self._get_resource("contest-type", key, _api.ContestType)

get_contest_effect

get_contest_effect(key: int) -> _api.ContestEffect

Get data about a contest effect.

Parameters:

Name Type Description Default
key int

id of the contest effect.

required

Returns:

Name Type Description
ContestEffect _api.ContestEffect

the parsed response from the API.

Source code in pypokeclient/async_client.py
183
184
185
186
187
188
189
190
191
192
193
@validate_call
async def get_contest_effect(self, key: int) -> _api.ContestEffect:
    """Get data about a contest effect.

    Args:
        key (int): id of the contest effect.

    Returns:
        ContestEffect: the parsed response from the API.
    """
    return await self._get_resource("contest-effect", key, _api.ContestEffect)

get_super_contest_effect

get_super_contest_effect(key: int) -> _api.SuperContestEffect

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 _api.SuperContestEffect

the parsed response from the API.

Source code in pypokeclient/async_client.py
195
196
197
198
199
200
201
202
203
204
205
@validate_call
async def get_super_contest_effect(self, key: int) -> _api.SuperContestEffect:
    """Get data about a super contest effect.

    Args:
        key (int): id of the super contest effect.

    Returns:
        SuperContestEffect: the parsed response from the API.
    """
    return await self._get_resource("super-contest-effect", key, _api.SuperContestEffect)

get_encounter_method

get_encounter_method(key: int | str) -> _api.EncounterMethod

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 _api.EncounterMethod

the parsed response from the API.

Source code in pypokeclient/async_client.py
210
211
212
213
214
215
216
217
218
219
220
@validate_call
async def get_encounter_method(self, key: int | str) -> _api.EncounterMethod:
    """Get data about an encounter method.

    Args:
        key (int | str): id or name of the encounter method.

    Returns:
        EncounterMethod: the parsed response from the API.
    """
    return await self._get_resource("encounter-method", key, _api.EncounterMethod)

get_encounter_condition

get_encounter_condition(key: int | str) -> _api.EncounterCondition

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 _api.EncounterCondition

the parsed response from the API.

Source code in pypokeclient/async_client.py
222
223
224
225
226
227
228
229
230
231
232
@validate_call
async def get_encounter_condition(self, key: int | str) -> _api.EncounterCondition:
    """Get data about an encounter condition.

    Args:
        key (int | str): id or name of the encounter condition.

    Returns:
        EncounterCondition: the parsed response from the API.
    """
    return await self._get_resource("encounter-condition", key, _api.EncounterCondition)

get_encounter_condition_value

get_encounter_condition_value(key: int | str) -> _api.EncounterConditionValue

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 _api.EncounterConditionValue

the parsed response from the API.

Source code in pypokeclient/async_client.py
234
235
236
237
238
239
240
241
242
243
244
@validate_call
async def get_encounter_condition_value(self, key: int | str) -> _api.EncounterConditionValue:
    """Get data about an encounter condition value.

    Args:
        key (int | str): id or name of the encounter condition.

    Returns:
        EncounterConditionValue: the parsed response from the API.
    """
    return await self._get_resource("encounter-condition-value", key, _api.EncounterConditionValue)

get_evolution_chain

get_evolution_chain(key: int) -> _api.EvolutionChain

Get data about an evolution chain.

Parameters:

Name Type Description Default
key int

id of the evolution chain.

required

Returns:

Name Type Description
EvolutionChain _api.EvolutionChain

the parsed response from the API.

Source code in pypokeclient/async_client.py
249
250
251
252
253
254
255
256
257
258
259
@validate_call
async def get_evolution_chain(self, key: int) -> _api.EvolutionChain:
    """Get data about an evolution chain.

    Args:
        key (int): id of the evolution chain.

    Returns:
        EvolutionChain: the parsed response from the API.
    """
    return await self._get_resource("evolution-chain", key, _api.EvolutionChain)

get_evolution_trigger

get_evolution_trigger(key: int | str) -> _api.EvolutionTrigger

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 _api.EvolutionTrigger

the parsed response from the API.

Source code in pypokeclient/async_client.py
261
262
263
264
265
266
267
268
269
270
271
@validate_call
async def get_evolution_trigger(self, key: int | str) -> _api.EvolutionTrigger:
    """Get data about an evolution trigger.

    Args:
        key (int | str): id or name of the evolution trigger.

    Returns:
        EvolutionTrigger: the parsed response from the API.
    """
    return await self._get_resource("evolution-trigger", key, _api.EvolutionTrigger)

get_generation

get_generation(key: int | str) -> _api.Generation

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 _api.Generation

the parsed response from the API.

Source code in pypokeclient/async_client.py
276
277
278
279
280
281
282
283
284
285
286
@validate_call
async def get_generation(self, key: int | str) -> _api.Generation:
    """Get data about a generation.

    Args:
        key (int | str): id or name of the generation.

    Returns:
        Generation: the parsed response from the API.
    """
    return await self._get_resource("generation", key, _api.Generation)

get_pokedex

get_pokedex(key: int | str) -> _api.Pokedex

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 _api.Pokedex

the parsed response from the API.

Source code in pypokeclient/async_client.py
288
289
290
291
292
293
294
295
296
297
298
@validate_call
async def get_pokedex(self, key: int | str) -> _api.Pokedex:
    """Get data about a Pokédex.

    Args:
        key (int | str): id or name of the Pokédex.

    Returns:
        Pokedex: the parsed response from the API.
    """
    return await self._get_resource("pokedex", key, _api.Pokedex)

get_version_group

get_version_group(key: int | str) -> _api.VersionGroup

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 _api.VersionGroup

the parsed response from the API.

Source code in pypokeclient/async_client.py
300
301
302
303
304
305
306
307
308
309
310
@validate_call
async def get_version_group(self, key: int | str) -> _api.VersionGroup:
    """Get data about a version group.

    Args:
        key (int | str): id or name of the version group.

    Returns:
        VersionGroup: the parsed response from the API.
    """
    return await self._get_resource("version-group", key, _api.VersionGroup)

get_version

get_version(key: int | str) -> _api.Version

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 _api.Version

the parsed response from the API.

Source code in pypokeclient/async_client.py
312
313
314
315
316
317
318
319
320
321
322
@validate_call
async def get_version(self, key: int | str) -> _api.Version:
    """Get data about a version.

    Args:
        key (int | str): id or name of the version.

    Returns:
        Version: the parsed response from the API.
    """
    return await self._get_resource("version", key, _api.Version)

get_item

get_item(key: int | str) -> _api.Item

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 _api.Item

the parsed response from the API.

Source code in pypokeclient/async_client.py
327
328
329
330
331
332
333
334
335
336
337
@validate_call
async def get_item(self, key: int | str) -> _api.Item:
    """Get data about an item.

    Args:
        key (int | str): id or name of the item.

    Returns:
        Item: the parsed response from the API.
    """
    return await self._get_resource("item", key, _api.Item)

get_item_attribute

get_item_attribute(key: int | str) -> _api.ItemAttribute

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 _api.ItemAttribute

the parsed response from the API.

Source code in pypokeclient/async_client.py
339
340
341
342
343
344
345
346
347
348
349
@validate_call
async def get_item_attribute(self, key: int | str) -> _api.ItemAttribute:
    """Get data about an item attribute.

    Args:
        key (int | str): id or name of the item attribute.

    Returns:
        ItemAttribute: the parsed response from the API.
    """
    return await self._get_resource("item-attribute", key, _api.ItemAttribute)

get_item_category

get_item_category(key: int | str) -> _api.ItemCategory

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 _api.ItemCategory

the parsed response from the API.

Source code in pypokeclient/async_client.py
351
352
353
354
355
356
357
358
359
360
361
@validate_call
async def get_item_category(self, key: int | str) -> _api.ItemCategory:
    """Get data about an item category.

    Args:
        key (int | str): id or name of the item category.

    Returns:
        ItemCategory: the parsed response from the API.
    """
    return await self._get_resource("item-category", key, _api.ItemCategory)

get_item_fling_effect

get_item_fling_effect(key: int | str) -> _api.ItemFlingEffect

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 _api.ItemFlingEffect

the parsed response from the API.

Source code in pypokeclient/async_client.py
363
364
365
366
367
368
369
370
371
372
373
@validate_call
async def get_item_fling_effect(self, key: int | str) -> _api.ItemFlingEffect:
    """Get data about an item fling effect.

    Args:
        key (int | str): id or name of the item fling effect.

    Returns:
        ItemFlingEffect: the parsed response from the API.
    """
    return await self._get_resource("item-fling-effect", key, _api.ItemFlingEffect)

get_item_pocket

get_item_pocket(key: int | str) -> _api.ItemPocket

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 _api.ItemPocket

the parsed response from the API.

Source code in pypokeclient/async_client.py
375
376
377
378
379
380
381
382
383
384
385
@validate_call
async def get_item_pocket(self, key: int | str) -> _api.ItemPocket:
    """Get data about an item pocket.

    Args:
        key (int | str): id or name of the item pocket.

    Returns:
        ItemPocket: the parsed response from the API.
    """
    return await self._get_resource("item-pocket", key, _api.ItemPocket)

get_location

get_location(key: int | str) -> _api.Location

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 _api.Location

the parsed response from the API.

Source code in pypokeclient/async_client.py
390
391
392
393
394
395
396
397
398
399
400
@validate_call
async def get_location(self, key: int | str) -> _api.Location:
    """Get data about a location.

    Args:
        key (int | str): id or name of the location.

    Returns:
        Location: the parsed response from the API.
    """
    return await self._get_resource("location", key, _api.Location)

get_location_area

get_location_area(key: int | str) -> _api.LocationArea

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 _api.LocationArea

the parsed response from the API.

Source code in pypokeclient/async_client.py
402
403
404
405
406
407
408
409
410
411
412
@validate_call
async def get_location_area(self, key: int | str) -> _api.LocationArea:
    """Get data about a location area.

    Args:
        key (int | str): id or name of the location area.

    Returns:
        LocationArea: the parsed response from the API.
    """
    return await self._get_resource("location-area", key, _api.LocationArea)

get_pal_park_area

get_pal_park_area(key: int | str) -> _api.PalParkArea

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 _api.PalParkArea

the parsed response from the API.

Source code in pypokeclient/async_client.py
414
415
416
417
418
419
420
421
422
423
424
@validate_call
async def get_pal_park_area(self, key: int | str) -> _api.PalParkArea:
    """Get data about a Pal Park area.

    Args:
        key (int | str): id or name of the Pal Park area.

    Returns:
        PalParkArea: the parsed response from the API.
    """
    return await self._get_resource("pal-park-area", key, _api.PalParkArea)

get_regions

get_regions(key: int | str) -> _api.Region

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 _api.Region

the parsed response from the API.

Source code in pypokeclient/async_client.py
426
427
428
429
430
431
432
433
434
435
436
@validate_call
async def get_regions(self, key: int | str) -> _api.Region:
    """Get data about a region.

    Args:
        key (int | str): id or name of the region.

    Returns:
        Region: the parsed response from the API.
    """
    return await self._get_resource("region", key, _api.Region)

get_machine

get_machine(key: int) -> _api.Machine

Get data about a machine.

Parameters:

Name Type Description Default
key int

id of the machine.

required

Returns:

Name Type Description
Machine _api.Machine

the parsed response from the API.

Source code in pypokeclient/async_client.py
441
442
443
444
445
446
447
448
449
450
451
@validate_call
async def get_machine(self, key: int) -> _api.Machine:
    """Get data about a machine.

    Args:
        key (int): id of the machine.

    Returns:
        Machine: the parsed response from the API.
    """
    return await self._get_resource("machine", key, _api.Machine)

get_move

get_move(key: int | str) -> _api.Move

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 _api.Move

the parsed response from the API.

Source code in pypokeclient/async_client.py
456
457
458
459
460
461
462
463
464
465
466
@validate_call
async def get_move(self, key: int | str) -> _api.Move:
    """Get data about a move.

    Args:
        key (int | str): id or name of the move.

    Returns:
        Move: the parsed response from the API.
    """
    return await self._get_resource("move", key, _api.Move)

get_move_ailment

get_move_ailment(key: int | str) -> _api.MoveAilment

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 _api.MoveAilment

the parsed response from the API.

Source code in pypokeclient/async_client.py
468
469
470
471
472
473
474
475
476
477
478
@validate_call
async def get_move_ailment(self, key: int | str) -> _api.MoveAilment:
    """Get data about a move ailment.

    Args:
        key (int | str): id or name of the move ailment.

    Returns:
        MoveAilment: the parsed response from the API.
    """
    return await self._get_resource("move-ailment", key, _api.MoveAilment)

get_move_battle_style

get_move_battle_style(key: int | str) -> _api.MoveBattleStyle

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 _api.MoveBattleStyle

the parsed response from the API.

Source code in pypokeclient/async_client.py
480
481
482
483
484
485
486
487
488
489
490
@validate_call
async def get_move_battle_style(self, key: int | str) -> _api.MoveBattleStyle:
    """Get data about a move battle style.

    Args:
        key (int | str): id or name of the move battle style.

    Returns:
        MoveBattleStyle: the parsed response from the API.
    """
    return await self._get_resource("move-battle-style", key, _api.MoveBattleStyle)

get_move_category

get_move_category(key: int | str) -> _api.MoveCategory

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 _api.MoveCategory

the parsed response from the API.

Source code in pypokeclient/async_client.py
492
493
494
495
496
497
498
499
500
501
502
@validate_call
async def get_move_category(self, key: int | str) -> _api.MoveCategory:
    """Get data about a move category.

    Args:
        key (int | str): id or name of the move category.

    Returns:
        MoveCategory: the parsed response from the API.
    """
    return await self._get_resource("move-category", key, _api.MoveCategory)

get_damage_class

get_damage_class(key: int | str) -> _api.MoveDamageClass

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 _api.MoveDamageClass

the parsed response from the API.

Source code in pypokeclient/async_client.py
504
505
506
507
508
509
510
511
512
513
514
@validate_call
async def get_damage_class(self, key: int | str) -> _api.MoveDamageClass:
    """Get data about a move damage class.

    Args:
        key (int | str): id or name of the move damage class.

    Returns:
        MoveDamageClass: the parsed response from the API.
    """
    return await self._get_resource("move-damage-class", key, _api.MoveDamageClass)

get_move_learn_method

get_move_learn_method(key: int | str) -> _api.MoveLearnMethod

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 _api.MoveLearnMethod

the parsed response from the API.

Source code in pypokeclient/async_client.py
516
517
518
519
520
521
522
523
524
525
526
@validate_call
async def get_move_learn_method(self, key: int | str) -> _api.MoveLearnMethod:
    """Get data about a move learn method.

    Args:
        key (int | str): id or name of the move learn method.

    Returns:
        MoveLearnMethod: the parsed response from the API.
    """
    return await self._get_resource("move-learn-method", key, _api.MoveLearnMethod)

get_move_target

get_move_target(key: int | str) -> _api.MoveTarget

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 _api.MoveTarget

the parsed response from the API.

Source code in pypokeclient/async_client.py
528
529
530
531
532
533
534
535
536
537
538
@validate_call
async def get_move_target(self, key: int | str) -> _api.MoveTarget:
    """Get data about a move target.

    Args:
        key (int | str): id or name of the move target.

    Returns:
        MoveTarget: the parsed response from the API.
    """
    return await self._get_resource("move-target", key, _api.MoveTarget)

get_ability

get_ability(key: int | str) -> _api.Ability

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 _api.Ability

the parsed response from the API.

Source code in pypokeclient/async_client.py
543
544
545
546
547
548
549
550
551
552
553
@validate_call
async def get_ability(self, key: int | str) -> _api.Ability:
    """Get data about an ability.

    Args:
        key (int | str): id or name of the ability.

    Returns:
        Ability: the parsed response from the API.
    """
    return await self._get_resource("ability", key, _api.Ability)

get_characteristic

get_characteristic(key: int) -> _api.Characteristic

Get data about a characteristic.

Parameters:

Name Type Description Default
key int

id of the characteristic.

required

Returns:

Name Type Description
Characteristic _api.Characteristic

the parsed response from the API.

Source code in pypokeclient/async_client.py
555
556
557
558
559
560
561
562
563
564
565
@validate_call
async def get_characteristic(self, key: int) -> _api.Characteristic:
    """Get data about a characteristic.

    Args:
        key (int): id of the characteristic.

    Returns:
        Characteristic: the parsed response from the API.
    """
    return await self._get_resource("characteristic", key, _api.Characteristic)

get_egg_group

get_egg_group(key: int | str) -> _api.EggGroup

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 _api.EggGroup

the parsed response from the API.

Source code in pypokeclient/async_client.py
567
568
569
570
571
572
573
574
575
576
577
@validate_call
async def get_egg_group(self, key: int | str) -> _api.EggGroup:
    """Get data about an egg group.

    Args:
        key (int | str): id or name of the egg group.

    Returns:
        EggGroup: the parsed response from the API.
    """
    return await self._get_resource("egg-group", key, _api.EggGroup)

get_gender

get_gender(key: int | str) -> _api.Gender

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 _api.Gender

the parsed response from the API.

Source code in pypokeclient/async_client.py
579
580
581
582
583
584
585
586
587
588
589
@validate_call
async def get_gender(self, key: int | str) -> _api.Gender:
    """Get data about a gender.

    Args:
        key (int | str): id or name of the gender.

    Returns:
        Gender: the parsed response from the API.
    """
    return await self._get_resource("gender", key, _api.Gender)

get_growth_rate

get_growth_rate(key: int | str) -> _api.GrowthRate

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 _api.GrowthRate

the parsed response from the API.

Source code in pypokeclient/async_client.py
591
592
593
594
595
596
597
598
599
600
601
@validate_call
async def get_growth_rate(self, key: int | str) -> _api.GrowthRate:
    """Get data about a growth rate.

    Args:
        key (int | str): id or name of the growth rate.

    Returns:
        GrowthRate: the parsed response from the API.
    """
    return await self._get_resource("growth-rate", key, _api.GrowthRate)

get_nature

get_nature(key: int | str) -> _api.Nature

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 _api.Nature

the parsed response from the API.

Source code in pypokeclient/async_client.py
603
604
605
606
607
608
609
610
611
612
613
@validate_call
async def get_nature(self, key: int | str) -> _api.Nature:
    """Get data about a nature.

    Args:
        key (int | str): id or name of the nature.

    Returns:
        Nature: the parsed response from the API.
    """
    return await self._get_resource("nature", key, _api.Nature)

get_pokeathlon_stat

get_pokeathlon_stat(key: int | str) -> _api.PokeathlonStat

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 _api.PokeathlonStat

the parsed response from the API.

Source code in pypokeclient/async_client.py
615
616
617
618
619
620
621
622
623
624
625
@validate_call
async def get_pokeathlon_stat(self, key: int | str) -> _api.PokeathlonStat:
    """Get data about a Pokéathlon stat.

    Args:
        key (int | str): id or name of the Pokéathlon stat.

    Returns:
        PokeathlonStat: the parsed response from the API.
    """
    return await self._get_resource("pokeathlon-stat", key, _api.PokeathlonStat)

get_pokemon

get_pokemon(key: int | str) -> _api.Pokemon

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 _api.Pokemon

the parsed response from the API.

Source code in pypokeclient/async_client.py
627
628
629
630
631
632
633
634
635
636
637
@validate_call
async def get_pokemon(self, key: int | str) -> _api.Pokemon:
    """Get data about a pokémon.

    Args:
        key (int | str): id or name of the pokémon

    Returns:
        Pokemon: the parsed response from the API.
    """
    return await self._get_resource("pokemon", key, _api.Pokemon)

get_pokemon_location_area

get_pokemon_location_area(key: int | str) -> list[_api.LocationAreaEncounter]

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[_api.LocationAreaEncounter]

the parsed response from the API.

Source code in pypokeclient/async_client.py
639
640
641
642
643
644
645
646
647
648
649
@validate_call
async def get_pokemon_location_area(self, key: int | str) -> list[_api.LocationAreaEncounter]:
    """Get data about a Pokémon's encounters in a location area.

    Args:
        key (int | str): id or name of the Pokémon.

    Returns:
        LocationAreaEncounter: the parsed response from the API.
    """
    return await self._get_resources(f"pokemon/{key}/encounters", "", _api.LocationAreaEncounter)

get_pokemon_color

get_pokemon_color(key: int | str) -> _api.PokemonColor

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 _api.PokemonColor

the parsed response from the API.

Source code in pypokeclient/async_client.py
651
652
653
654
655
656
657
658
659
660
661
@validate_call
async def get_pokemon_color(self, key: int | str) -> _api.PokemonColor:
    """Get data about a Pokémon color.

    Args:
        key (int | str): id or name of the Pokémon color.

    Returns:
        PokemonColor: the parsed response from the API.
    """
    return await self._get_resource("pokemon-color", key, _api.PokemonColor)

get_pokemon_form

get_pokemon_form(key: int | str) -> _api.PokemonForm

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 _api.PokemonForm

the parsed response from the API.

Source code in pypokeclient/async_client.py
663
664
665
666
667
668
669
670
671
672
673
@validate_call
async def get_pokemon_form(self, key: int | str) -> _api.PokemonForm:
    """Get data about a Pokémon form.

    Args:
        key (int | str): id or name of the Pokémon form.

    Returns:
        PokemonForm: the parsed response from the API.
    """
    return await self._get_resource("pokemon-form", key, _api.PokemonForm)

get_pokemon_habitat

get_pokemon_habitat(key: int | str) -> _api.PokemonHabitat

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 _api.PokemonHabitat

the parsed response from the API.

Source code in pypokeclient/async_client.py
675
676
677
678
679
680
681
682
683
684
685
@validate_call
async def get_pokemon_habitat(self, key: int | str) -> _api.PokemonHabitat:
    """Get data about a Pokémon habitat.

    Args:
        key (int | str): id or name of the Pokémon habitat.

    Returns:
        PokemonHabitat: the parsed response from the API.
    """
    return await self._get_resource("pokemon-habitat", key, _api.PokemonHabitat)

get_pokemon_shape

get_pokemon_shape(key: int | str) -> _api.PokemonShape

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 _api.PokemonShape

the parsed response from the API.

Source code in pypokeclient/async_client.py
687
688
689
690
691
692
693
694
695
696
697
@validate_call
async def get_pokemon_shape(self, key: int | str) -> _api.PokemonShape:
    """Get data about a Pokémon shape.

    Args:
        key (int | str): id or name of the Pokémon shape.

    Returns:
        PokemonShape: the parsed response from the API.
    """
    return await self._get_resource("pokemon-shape", key, _api.PokemonShape)

get_pokemon_species

get_pokemon_species(key: int | str) -> _api.PokemonSpecies

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 _api.PokemonSpecies

the parsed response from the API.

Source code in pypokeclient/async_client.py
699
700
701
702
703
704
705
706
707
708
709
@validate_call
async def get_pokemon_species(self, key: int | str) -> _api.PokemonSpecies:
    """Get data about a Pokémon species.

    Args:
        key (int | str): id or name of the Pokémon species.

    Returns:
        PokemonSpecies: the parsed response from the API.
    """
    return await self._get_resource("pokemon-species", key, _api.PokemonSpecies)

get_stat

get_stat(key: int | str) -> _api.Stat

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 _api.Stat

the parsed response from the API.

Source code in pypokeclient/async_client.py
711
712
713
714
715
716
717
718
719
720
721
@validate_call
async def get_stat(self, key: int | str) -> _api.Stat:
    """Get data about a stat.

    Args:
        key (int | str): id or name of the stat.

    Returns:
        Stat: the parsed response from the API.
    """
    return await self._get_resource("stat", key, _api.Stat)

get_type

get_type(key: int | str) -> _api.Type

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 _api.Type

the parsed response from the API.

Source code in pypokeclient/async_client.py
723
724
725
726
727
728
729
730
731
732
733
@validate_call
async def get_type(self, key: int | str) -> _api.Type:
    """Get data about a type.

    Args:
        key (int | str): id or name of the type.

    Returns:
        Type: the parsed response from the API.
    """
    return await self._get_resource("type", key, _api.Type)

get_language

get_language(key: int | str) -> _api.Language

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 _api.Language

the parsed response from the API.

Source code in pypokeclient/async_client.py
738
739
740
741
742
743
744
745
746
747
748
@validate_call
async def get_language(self, key: int | str) -> _api.Language:
    """Get infos about a language.

    Args:
        key (int | str): id or name of the pokémon

    Returns:
        Language: the parsed response from the API.
    """
    return await self._get_resource("language", key, _api.Language)

get_sprite

get_sprite(url: str) -> _api.Sprite

Get a sprite from an url.

Parameters:

Name Type Description Default
url str

the url to the sprite.

required

Returns:

Name Type Description
Sprite _api.Sprite

a Sprite object useful to save the image.

Source code in pypokeclient/async_client.py
753
754
755
756
757
758
759
760
761
762
763
764
@validate_call
async def get_sprite(self, url: str) -> _api.Sprite:
    """Get a sprite from an url.

    Args:
        url (str): the url to the sprite.

    Returns:
        Sprite: a Sprite object useful to save the image.
    """
    response = await self._api_request(url)
    return _api.Sprite(url, response.content)