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.2.7.tar.gz
(55.6 kB
view details)
Built Distribution
pokelance-0.2.7-py3-none-any.whl
(78.4 kB
view details)
File details
Details for the file pokelance-0.2.7.tar.gz
.
File metadata
- Download URL: pokelance-0.2.7.tar.gz
- Upload date:
- Size: 55.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.1 Linux/6.2.0-1019-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0aab247e1a612469cfd239582c771202dc205cb3f7beba33f0e8f6c7b18b1af |
|
MD5 | 2f9eaec4a0ad8bda96144d9848af43e7 |
|
BLAKE2b-256 | 8d5acf7e204166034d0b2c1c2a75a7af6872aa8ee922fd4bcda4740657b0b8e3 |
File details
Details for the file pokelance-0.2.7-py3-none-any.whl
.
File metadata
- Download URL: pokelance-0.2.7-py3-none-any.whl
- Upload date:
- Size: 78.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.1 Linux/6.2.0-1019-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a688b850f7a3a3a6310e2a70cc86260cbeedd3faa733a93980315d09273de727 |
|
MD5 | fea582174794d79a866967ee5cda7052 |
|
BLAKE2b-256 | 770e1330da88665032dd1cca4cd2b1f1c7b7f74bbe4b3fc67f9b7f9792a4e5ab |