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._api import Pokemon

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

💾 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

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.

Metadata

Release files for pypokeclient 2.3.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 2.3.0
File Size Uploaded
pypokeclient-2.3.0.tar.gz 602.4 kB Details

Built distribution (wheel)

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

Total release size: 643.2 kB

Release files / pypokeclient-2.3.0.tar.gz

Download URL pypokeclient-2.3.0.tar.gz
Size 602.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0181409f8ce60065e6c36e31117893a67dc6013db5094565054590a77df39876
BLAKE2b-256 checksum
How to use checksums
2c228551b87c7f6ebc81835f02a16953cab3a34aa1357a7c886f484872b97e12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 1, 2026.

Transparency log

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

Download URL pypokeclient-2.3.0-py3-none-any.whl
Size 40.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
82421425f04e168cb840f9d30c3738397a6227d9117b3c2f08553598ed7f2cd9
BLAKE2b-256 checksum
How to use checksums
ce8d42a0afb34ca2730c878994b8c3fda37e6c1e15c509658059712bd5679d37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.3.0 This release

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release 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