A flexible and easy to use pokemon library.
Project description
PokeLance
A flexible, statically typed and easy to use pokeapi wrapper for python 🚀
Features:
- Modern and pythonic API asynchronously built on top of aiohttp
- Flexible and easy to use
- Statically typed with mypy
- Linted with ruff
- Well documented
- Optimized for speed and performance
- Automatically caches data for faster access
- Caches endpoints for user convenience
Installation
$ python -m pip install PokeLance
Usage
import asyncio
from pokelance import PokeLance
client = PokeLance() # Create a client instance
async def main() -> None:
print(await client.ping()) # Ping the pokeapi
print(await client.berry.fetch_berry("cheri")) # Fetch a berry from the pokeapi
print(await client.berry.fetch_berry_flavor("spicy"))
print(await client.berry.fetch_berry_firmness("very-soft"))
print(client.berry.get_berry("cheri")) # Get a cached berry it will return None if it doesn't exist
print(client.berry.get_berry_flavor("spicy"))
print(client.berry.get_berry_firmness("very-soft"))
await client.close() # Close the client
return None
asyncio.run(main())
With Async Context Manager
import asyncio
import aiohttp
from pokelance import PokeLance
async def main() -> None:
# Use an async context manager to create a client instance
async with aiohttp.ClientSession() as session, PokeLance(session=session) as client:
print(await client.ping()) # Ping the pokeapi
print(await client.berry.fetch_berry("cheri")) # Fetch a berry from the pokeapi
print(await client.berry.fetch_berry_flavor("spicy"))
print(await client.berry.fetch_berry_firmness("very-soft"))
print(client.berry.get_berry("cheri")) # Get a cached berry it will return None if it doesn't exist
print(client.berry.get_berry_flavor("spicy"))
print(client.berry.get_berry_firmness("very-soft"))
# The client will be closed automatically when the async context manager exits
return None
asyncio.run(main())
Examples
Following examples are available open an issue if you want more examples or more details on certain examples.
- Basic Usage
- Advanced cache usage
- Discord bot example
- FastAPI example
Important Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pokelance-0.1.9.tar.gz
(52.0 kB
view details)
Built Distribution
pokelance-0.1.9-py3-none-any.whl
(74.9 kB
view details)
File details
Details for the file pokelance-0.1.9.tar.gz
.
File metadata
- Download URL: pokelance-0.1.9.tar.gz
- Upload date:
- Size: 52.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.1 Linux/6.2.0-1018-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6715b2f1a9b98df9ebb15f0fa9d45794b8b2a561b59cb8808d985dc486444391 |
|
MD5 | 83e7462b824eae22837a5ca74c349640 |
|
BLAKE2b-256 | a77b31a8d4ca026292c93bb93227267e7322a77f146aef9bf3fe372184d0c424 |
File details
Details for the file pokelance-0.1.9-py3-none-any.whl
.
File metadata
- Download URL: pokelance-0.1.9-py3-none-any.whl
- Upload date:
- Size: 74.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.1 Linux/6.2.0-1018-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f64bfa6954d664e7ca2cfb58917b5b3117234da65c3be26fe053b3a0ba66f8e9 |
|
MD5 | 7bf801fedd53b8edcab122b67d3ec3c1 |
|
BLAKE2b-256 | 1bf63470a2c8425f299b6c9d9c6a99af65d15620dda98a3ef6e7f3f01ae1fa5e |