Skip to main content

PyPokéClient

Synchronous and asynchronous clients to fetch data from PokéAPI.

Python Pydantic

PyPI Python versions


📌 Features

  • Coverage: all PokéAPI endpoints are covered.
  • Data validation: uses Pydantic dataclasses for the API implementation.
  • Flexibility: can choose between synchronous and asynchronous clients.
  • Caching: can employ a local cache system for faster responses and to respect PokéAPI Fair Use policy.

Please have a look at the documentation for more details about the package.


📦 Installation

# It is highly recommended to use uv
uv add pypokeclient

# But you can also install the package via pip
pip install pypokeclient

🛠️ How to use

You can choose whether to use the synchronous client

from pypokeclient import Client

# Simple usage
client = Client()
pokemon = client.get_pokemon("fuecoco")

# Or with context manager
with Client() as client:
  pokemon = client.get_pokemon("fuecoco")

or the asynchronous one

import asyncio

from pypokeclient import AsyncClient


async def fetch_data():
  # Simple usage
  client = AsyncClient()
  pokemon = await client.get_pokemon("fuecoco")

  # With context manager
  async with AsyncClient() as client:
    pokemon = await client.get_pokemon("fuecoco")

asyncio.run(fetch_data())

💾 Caching the results

[!IMPORTANT] Please refer to the hishel documentation for more details about the caching system.

import logging

from hishel import SyncSqliteStorage
from hishel.httpx import SyncCacheClient
from pypokeclient import Client

# Set up the logger
logger = logging.getLogger("pypokeclient")
logger.setLevel(logging.INFO)
console_handler = logging.StreamHandler()
console_handler.setFormatter(logging.Formatter("%(name)s - %(levelname)s - %(message)s"))
logger.addHandler(console_handler)

# Set up the underlying HTTP client
http_client = SyncCacheClient(
    storage=SyncSqliteStorage(database_path="pypokeclient_cache.db")
)

# Fetch data
with Client(http_client) as sync_client:
    pokemon = sync_client.get_pokemon("fuecoco")
    pokemon = sync_client.get_pokemon("fuecoco")

    # The sprites are cached too
    sprite = sync_client.get_sprite(pokemon.sprites.front_default)
    sprite = sync_client.get_sprite(pokemon.sprites.front_default)

    # You can also save the sprites locally if needed
    sprite.save("fuecoco.png")

The output will be the following

pypokeclient - INFO - The synchronous client is ready and using the cache at .cache\hishel\pypokeclient_cache.db'.
pypokeclient - INFO - [200] Request to https://pokeapi.co/api/v2/pokemon/fuecoco.
pypokeclient - INFO - [200] Cached request to https://pokeapi.co/api/v2/pokemon/fuecoco.
pypokeclient - INFO - [200] Request to https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/909.png.
pypokeclient - INFO - [200] Cached request to https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/909.png.
pypokeclient - INFO - Closed session for the synchronous client.

📝 License

This project is MIT licensed.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypokeclient-2.2.1.tar.gz (599.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pypokeclient-2.2.1-py3-none-any.whl (39.3 kB view details)

Uploaded Python 3

File details

Details for the file pypokeclient-2.2.1.tar.gz.

File metadata

  • Download URL: pypokeclient-2.2.1.tar.gz
  • Upload date:
  • Size: 599.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for pypokeclient-2.2.1.tar.gz
Algorithm Hash digest
SHA256 79350f215f29e6df811d0fe03f6f9c288e65252885c33ed94e155d60529aef2e
MD5 9c6628d9c7f688580d8ab571cf05b795
BLAKE2b-256 16f80f2b864a98eabf4d8db426848f4e089585a6a19ad1b6568aab67764e2346

See more details on using hashes here.

Provenance

The following attestation bundles were made for pypokeclient-2.2.1.tar.gz:

Publisher: publish-to-pypi.yml on RistoAle97/pokeapi-python-wrapper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pypokeclient-2.2.1-py3-none-any.whl.

File metadata

  • Download URL: pypokeclient-2.2.1-py3-none-any.whl
  • Upload date:
  • Size: 39.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for pypokeclient-2.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 edc0a500759be9a2f46c8915d63eff9077c9ec67ec1c334f81b4afed2bcfcd9c
MD5 e44c973b0878de948fa0f04dab3a802e
BLAKE2b-256 505b10778f95759e82ef13752b66bb83f2747119ed4a4eee62c5a2223d6ce773

See more details on using hashes here.

Provenance

The following attestation bundles were made for pypokeclient-2.2.1-py3-none-any.whl:

Publisher: publish-to-pypi.yml on RistoAle97/pokeapi-python-wrapper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

2.2.1 This release

2 files

2.2.0

2 files

2.1.0

2 files

2.0.2

2 files

2.0.1

2 files

2.0.0

2 files

1.1.0

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0.post1

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page