Skip to main content

PyPokéClient

Synchronous and asynchronous clients for fetching data from PokéAPI.

Python Pydantic

PyPI Python versions

📌 Features

  • Coverage: covers all PokéAPI endpoints.
  • Data validation: uses Pydantic dataclasses to model and validate API responses.
  • Flexibility: provides both synchronous and asynchronous clients.
  • Caching: supports an optional local caching system for faster responses and to help comply with PokéAPI's Fair Use Policy.

Please refer to the documentation for more details about the package.

📦 Installation

# It is highly recommended to use uv
uv add pypokeclient

# You can also install the package with pip
pip install pypokeclient

🛠️ How to use

You can choose between the synchronous and asynchronous clients.

Sync

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")

Async

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())

No client

If you want to build your own client, including the caching mechanism, while still benefiting from Pydantic dataclasses, you can use the data models directly.

import requests
from pypokeclient.models import Pokemon

resp = requests.get("https://pokeapi.co/api/v2/pokemon/fuecoco")
pokemon = Pokemon(**resp.json())

💾 Caching the results

First, install the cache optional dependencies

uv add pypokeclient[cache]

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

import logging

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

# Set up the logger
logger = logging.getLogger("pypokeclient")
logger.setLevel(logging.DEBUG)
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"),
    base_url="https://pokeapi.co/api/v2/",
)

# 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

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

📝 License

This project is MIT licensed.

Metadata

Release files for pypokeclient 3.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pypokeclient 3.0.0
File Size Uploaded Provenance Actions
pypokeclient-3.0.0.tar.gz 627.1 kB With provenance Details for pypokeclient-3.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pypokeclient 3.0.0
File Interpreter ABI Platform Actions
pypokeclient-3.0.0-py3-none-any.whl Python 3 none any Details for pypokeclient-3.0.0-py3-none-any.whl

Total release size: 692.7 kB

Release files / pypokeclient-3.0.0.tar.gz

Download URL pypokeclient-3.0.0.tar.gz
Size 627.1 kB
Tags Source
SHA-256 checksum
How to use checksums
551a0a26869bc53b436c4ef8fdb8fb9cc4828243e98a4e48c675e5f107193338
BLAKE2b-256 checksum
How to use checksums
5d3eaa1a3a4c6b77109d69a7a4a126b6803b14c50665eb4f851353298e3862c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / pypokeclient-3.0.0-py3-none-any.whl

Download URL pypokeclient-3.0.0-py3-none-any.whl
Size 65.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
19f2649179bb9244f961e75dab96f55dd4b8da5dac18eb3e73b14616e13f6956
BLAKE2b-256 checksum
How to use checksums
ff514ac368d4363feb74e2c5ad95a2a5dc2d1ec287584195c1a742a635961d81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Security for pypokeclient 3.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pypokeclient-3.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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