Skip to main content

Python library for interacting with the `pokeapi` API

Project description

PokeAPI SDK

A Python SDK for PokeAPI, providing easy access to Pokémon data.

Installation

Install pokepy_sdk with Python's pip package manager: pip install pokeapi-sdk

Usage

First, instantiate a client:``` from pokeapi_sdk.client import PokeAPIClient client = PokeAPIClient()


With a `PokeAPIClient` object:
- 1: Get a Pokémon by name (str) or ID (int)

pokemon = client.get_pokemon("pikachu") print(pokemon.name, pokemon.abilities)

This returns a `Pokemon` object.

- 2: Get a generation by name (str) or ID (int)

generation = client.get_generation(1) print(generation.name, generation.pokemon_species)

This returns a `Generation` object.

- 3: Get a summary of every Pokemon:

all_pokemon = client.get_all_pokemon_summaries()

This returns a list of `PokemonSummary` objects.

- 4: Get a summary of every Generation:

all_generations = client.get_all_generation_summaries()

This returns a list of `GenerationSummary` objects.

Both `get_all_pokemon_summaries()` & `get_all_generation_summaries()` support optional offset-based pagiation parameters:
- `offset`: The starting point within the collection 
- `page_size`: The maximum number of objects to return in the request

## Testing

To run the unit tests:
`pytest`

To run the integration tests:
`pytest pokep_sdky/tests/integration_tests.py`

## Design Decisions 
- **Pagination**: Optional offset-based pagination is supported when fetching all Pokemon & all Pokemon generations. 
- **Pydantic data validation**: Pydantic provides excellent validation tools for instantiation of class instances
- **Error Handling**: Comprehensive HTTP error handling for all requests
- **Abstractions**: Significant use of classes & a client object to simplify user experience
- **Package management with Poetry**: Poetry provides intuitive dependency & package management
- **Rate Limit Handling**: PokeAPI does not currently impose API rate limits, but a simple rate limit handler has been included for all requests
- **`__str__` & `__repr__` overrides**: For improved informational display of class instances

## Tools Used
- `black` formatter: https://github.com/psf/black
- `ruff` linting & formatting: https://docs.astral.sh/ruff/
- `mypy` for static type checking: https://github.com/python/mypy
- `pytest` for unit test & integration tests https://docs.pytest.org/en/stable/
- `tenacity` for handling rate limiting: https://github.com/jd/tenacity

Project details


Download files

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

Source Distribution

pokepy_sdk-0.1.0.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

pokepy_sdk-0.1.0-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file pokepy_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: pokepy_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for pokepy_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 901d5d8ec1785d2ec66cefc152bc296bdde2e7a51ff2fb36752fe0568fe9b57b
MD5 2a0a2f81b2ff922f9aa768165e41d750
BLAKE2b-256 9a5d0c45cbe128e8bf06a9efcba68890ebd6742b6ddb7d9344a10de31d0d469a

See more details on using hashes here.

File details

Details for the file pokepy_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pokepy_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for pokepy_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6cf8d97fe3b9489663b40a20a504bc5c8dce88917aa4148fc62be006f180a04b
MD5 c03b838bb0e05be125b986bffd4f456b
BLAKE2b-256 55e4906761384acc3fd5a1cb1b2c64af1a0371958116b943155a5e176b19b411

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page