Skip to main content

Pokebase swampert

actions Python 3.6 pypi Python >=3.8 github

pokebase is a simple but powerful Python interface to the PokéAPI database

Maintainer: GregHilmes

Installation

Version Support

pokebase 1.3.0 supports Python 3.6. Install it with pip install pokebase

pokebase 1.4.0 drops support for Python 3.6 and adds support for Python >=3.8 <=3.12. Install it with pip install https://github.com/PokeAPI/pokebase/archive/1.4.0.zip

Usage

>>> import pokebase as pb
>>> chesto = pb.APIResource('berry', 'chesto')
>>> chesto.name
'chesto'
>>>
chesto.natural_gift_type.name
'water'
>>> charmander = pb.pokemon('charmander') # Quick lookup.
>>> charmander.height
6
>>> # Now with sprites! (again!)
>>> s1 = pb.SpriteResource('pokemon', 17)
<pokebase.interface.SpriteResource object at 0x7f2f15660860>
>>> s1.url
'<https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/17.png>'
>>> s2 = pb.SpriteResource('pokemon', 1, other=True, official_artwork=True)
>>> s2.path
'/home/user/.cache/pokebase/sprite/pokemon/other-sprites/official-artwork/1.png'
>>> s3 = pb.SpriteResource('pokemon', 3, female=True, back=True)
>>> s3.img_data b'x89PNGrnx1anx00x00x00rIHDRx00x00x00 ... xca^x7fxbbd\*x00x00x00x00IENDxaeB`x82'

... And it's just that simple.

Nomenclature

  • an endpoint is the results of an API call like http://pokeapi.co/api/v2/berry or http://pokeapi.co/api/v2/move
  • a resource is the actual data, from a call to http://pokeapi.co/api/v2/pokemon/1

Testing

Python unit tests are in a separate tests directory and can be run via python -m tests.

Notes to the developer using this module

The quick data lookup for a Pokémon type, is pokebase.type_('type-name'), not pokebase.type('type-name'). This is because of a naming conflict with the built-in type function, were you to from pokebase import *.

When changing the cache, avoid importing the cache constants directly. You should only import them with the whole cache module. If you do not do this, calling set_cache will not change your local copy of the variable.

NOT THIS!

>>> from pokebase.cache import API_CACHE

Do this :)

>>> from pokebase import cache
>>> cache.API_CACHE

Metadata

Release files for pokebase 1.4.1

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

Source distribution (sdist)

Source distribution for pokebase 1.4.1
File Size Uploaded
pokebase-1.4.1.tar.gz 15.5 kB Details

Built distribution (wheel)

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

Total release size: 27.3 kB

Release files / pokebase-1.4.1.tar.gz

Download URL pokebase-1.4.1.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
036116b1696dce7ef96ead3e892476648d6e3eec52fbd1e63677f944de259ecc
BLAKE2b-256 checksum
How to use checksums
cff50c827ba3ed055c9a266ca809ebaf152a6d6b0a7932d9a48b78d471dbd2ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / pokebase-1.4.1-py3-none-any.whl

Download URL pokebase-1.4.1-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0c3f6dcd010711f5e7e9e4bc9a0bacf094b92a9144499c449c35f00a8ce46478
BLAKE2b-256 checksum
How to use checksums
776fc96b0855965a1d151fc930168ed2e78f7c414872531899036f0b4b5093d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

1.4.1 This release

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

1 release file

1.1.0

1 release file

1.0.0

1 release file

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