Routes
endpoints
¶
Route
¶
Represents a route for an endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
endpoint |
str
|
The endpoint name. |
_url |
str
|
The URL for the route. |
_api_version |
int
|
The API version for the route. |
method |
str
|
The HTTP method for the route. |
payload |
Optional[Dict[str, Any]]
|
The payload for the route. |
Examples:
from_raw_url
classmethod
¶
Creates a Route object from a raw PokeAPI URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The raw URL to create the Route from. |
required |
Returns:
| Type | Description |
|---|---|
Route
|
The created Route object. |
Source code in pokelance/endpoints.py
@classmethod
def from_raw_url(cls, url: str) -> Route:
"""Creates a Route object from a raw PokeAPI URL.
Parameters
----------
url: str
The raw URL to create the Route from.
Returns
-------
Route
The created Route object.
"""
match = validate_url(url)
if not match:
raise ValueError(f"Invalid URL: {url}")
category, value, subcategory = match.groups()
return cls(endpoint=f"/{category}/{value}" + (f"/{subcategory}" if subcategory else ""))
Endpoint
¶
Represents an endpoint for the API.
get_language
classmethod
¶
get_berry
classmethod
¶
get_berry_firmness
classmethod
¶
get_berry_flavor
classmethod
¶
get_contest_type
classmethod
¶
get_contest_effect
classmethod
¶
get_super_contest_effect
classmethod
¶
get_encounter_method
classmethod
¶
get_encounter_condition
classmethod
¶
get_encounter_condition_value_endpoints
classmethod
¶
get_encounter_condition_value_endpoints() -> Route
get_encounter_condition_value
classmethod
¶
Get an encounter condition value by its ID or name.
get_evolution_chain
classmethod
¶
get_evolution_trigger
classmethod
¶
get_generation
classmethod
¶
get_pokedex
classmethod
¶
get_version
classmethod
¶
get_version_group
classmethod
¶
get_currency
classmethod
¶
get_item
classmethod
¶
get_item_attribute
classmethod
¶
get_item_category
classmethod
¶
get_item_fling_effect
classmethod
¶
get_item_pocket
classmethod
¶
get_location
classmethod
¶
get_location_area
classmethod
¶
get_pal_park_area
classmethod
¶
get_region
classmethod
¶
get_machine
classmethod
¶
get_move
classmethod
¶
get_move_ailment
classmethod
¶
get_move_battle_style
classmethod
¶
get_move_category
classmethod
¶
get_move_damage_class
classmethod
¶
get_move_learn_method
classmethod
¶
get_move_target
classmethod
¶
get_ability
classmethod
¶
get_characteristic
classmethod
¶
get_egg_group
classmethod
¶
get_gender
classmethod
¶
get_growth_rate
classmethod
¶
get_nature
classmethod
¶
get_location_area_encounter_endpoints
classmethod
¶
get_location_area_encounter_endpoints() -> Route