Name | pokepy-sdk JSON |
Version |
0.1.0
JSON |
| download |
home_page | None |
Summary | Python library for interacting with the `pokeapi` API |
upload_time | 2024-09-23 12:32:19 |
maintainer | None |
docs_url | None |
author | Your Name |
requires_python | <4.0,>=3.8 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 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
Raw data
{
"_id": null,
"home_page": null,
"name": "pokepy-sdk",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Your Name",
"author_email": "john1091w@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/9a/5d/0c45cbe128e8bf06a9efcba68890ebd6742b6ddb7d9344a10de31d0d469a/pokepy_sdk-0.1.0.tar.gz",
"platform": null,
"description": "# PokeAPI SDK\n\nA Python SDK for PokeAPI, providing easy access to Pok\u00e9mon data.\n\n## Installation\nInstall `pokepy_sdk` with Python's `pip` package manager:\n`pip install pokeapi-sdk`\n\n## Usage\nFirst, instantiate a client:```\nfrom pokeapi_sdk.client import PokeAPIClient\nclient = PokeAPIClient()\n```\n\nWith a `PokeAPIClient` object:\n- 1: Get a Pok\u00e9mon by name (str) or ID (int)\n```\npokemon = client.get_pokemon(\"pikachu\")\nprint(pokemon.name, pokemon.abilities)\n```\nThis returns a `Pokemon` object.\n\n- 2: Get a generation by name (str) or ID (int)\n```\ngeneration = client.get_generation(1)\nprint(generation.name, generation.pokemon_species)\n```\nThis returns a `Generation` object.\n\n- 3: Get a summary of every Pokemon:\n```\nall_pokemon = client.get_all_pokemon_summaries()\n```\nThis returns a list of `PokemonSummary` objects.\n\n- 4: Get a summary of every Generation:\n```\nall_generations = client.get_all_generation_summaries()\n```\nThis returns a list of `GenerationSummary` objects.\n\nBoth `get_all_pokemon_summaries()` & `get_all_generation_summaries()` support optional offset-based pagiation parameters:\n- `offset`: The starting point within the collection \n- `page_size`: The maximum number of objects to return in the request\n\n## Testing\n\nTo run the unit tests:\n`pytest`\n\nTo run the integration tests:\n`pytest pokep_sdky/tests/integration_tests.py`\n\n## Design Decisions \n- **Pagination**: Optional offset-based pagination is supported when fetching all Pokemon & all Pokemon generations. \n- **Pydantic data validation**: Pydantic provides excellent validation tools for instantiation of class instances\n- **Error Handling**: Comprehensive HTTP error handling for all requests\n- **Abstractions**: Significant use of classes & a client object to simplify user experience\n- **Package management with Poetry**: Poetry provides intuitive dependency & package management\n- **Rate Limit Handling**: PokeAPI does not currently impose API rate limits, but a simple rate limit handler has been included for all requests\n- **`__str__` & `__repr__` overrides**: For improved informational display of class instances\n\n## Tools Used\n- `black` formatter: https://github.com/psf/black\n- `ruff` linting & formatting: https://docs.astral.sh/ruff/\n- `mypy` for static type checking: https://github.com/python/mypy\n- `pytest` for unit test & integration tests https://docs.pytest.org/en/stable/\n- `tenacity` for handling rate limiting: https://github.com/jd/tenacity\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python library for interacting with the `pokeapi` API",
"version": "0.1.0",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "55e4906761384acc3fd5a1cb1b2c64af1a0371958116b943155a5e176b19b411",
"md5": "c03b838bb0e05be125b986bffd4f456b",
"sha256": "6cf8d97fe3b9489663b40a20a504bc5c8dce88917aa4148fc62be006f180a04b"
},
"downloads": -1,
"filename": "pokepy_sdk-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c03b838bb0e05be125b986bffd4f456b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 20920,
"upload_time": "2024-09-23T12:32:17",
"upload_time_iso_8601": "2024-09-23T12:32:17.605804Z",
"url": "https://files.pythonhosted.org/packages/55/e4/906761384acc3fd5a1cb1b2c64af1a0371958116b943155a5e176b19b411/pokepy_sdk-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9a5d0c45cbe128e8bf06a9efcba68890ebd6742b6ddb7d9344a10de31d0d469a",
"md5": "2a0a2f81b2ff922f9aa768165e41d750",
"sha256": "901d5d8ec1785d2ec66cefc152bc296bdde2e7a51ff2fb36752fe0568fe9b57b"
},
"downloads": -1,
"filename": "pokepy_sdk-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "2a0a2f81b2ff922f9aa768165e41d750",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 18407,
"upload_time": "2024-09-23T12:32:19",
"upload_time_iso_8601": "2024-09-23T12:32:19.149862Z",
"url": "https://files.pythonhosted.org/packages/9a/5d/0c45cbe128e8bf06a9efcba68890ebd6742b6ddb7d9344a10de31d0d469a/pokepy_sdk-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-23 12:32:19",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "pokepy-sdk"
}