https://github.com/fallendeity/pokelance
An asynchronous api wrapper wrapping around pokeapi with auto data and image caching.
https://github.com/fallendeity/pokelance
asyncio pokeapi pokedex pokemon pokemon-api python3
Last synced: about 1 year ago
JSON representation
An asynchronous api wrapper wrapping around pokeapi with auto data and image caching.
- Host: GitHub
- URL: https://github.com/fallendeity/pokelance
- Owner: FallenDeity
- License: mit
- Created: 2022-12-10T04:59:18.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-03-25T13:15:54.000Z (over 2 years ago)
- Last Synced: 2024-04-23T21:18:21.922Z (about 2 years ago)
- Topics: asyncio, pokeapi, pokedex, pokemon, pokemon-api, python3
- Language: Python
- Homepage: https://fallendeity.github.io/PokeLance/
- Size: 2.63 MB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
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
```bash
$ python -m pip install PokeLance
```
---
## Usage
```python
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
```python
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
[Examples](https://fallendeity.github.io/PokeLance/guide/basic_usage/)
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
- [PokeAPI](https://pokeapi.co/)
- [PokeAPI Documentation](https://pokeapi.co/docs/v2)
- [PokeLance Documentation](https://FallenDeity.github.io/PokeLance/)
- [PokeLance ReadTheDocs](https://pokelance.readthedocs.io/en/latest/)
- [PokeLance GitHub](https://github.com/FallenDeity/PokeLance)
- [PokeLance PyPI](https://pypi.org/project/PokeLance/)
- [PokeLance Discord](https://discord.gg/yeyEvT5V2J)