Skip to main content

A Python wrapper for the friendly PokeAPI database

Project description

Pokebase swampert

travis pypi

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

Maintainer: GregHilmes

Important

pokebase is under heavy construction right now, in order to clean up the code and make it easier to maintain. I recommend you continue using version 1.3.0, download via pip. Once these new changes are stable, there will be another PyPI release.

Installation

pip install pokebase

It can’t get much easier than that.

Pokebase has been tested against Python 3.6 and Python 3.6 only. If this is too old for your needs, see the above note about the construction. Pokebase may function under other version of Python, but bugs may occur.

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_sprites=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'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 ... \xca^\x7f\xbbd*\x00\x00\x00\x00IEND\xaeB`\x82'

… And it’s just that simple.

Version Support

pokebase currently (officially) supports Python 3.6

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 unittests 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

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

pokebase-1.3.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

pokebase-1.3.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file pokebase-1.3.0.tar.gz.

File metadata

  • Download URL: pokebase-1.3.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.10

File hashes

Hashes for pokebase-1.3.0.tar.gz
Algorithm Hash digest
SHA256 1fab389df211f22d0987e8aae45d0d19b5db7b3eb0c92dca48283f74e9df4f70
MD5 65897eb9bb80ff5d8847a2e688ca8309
BLAKE2b-256 c19e7d111c9334ef8b99cd96ad23f2b5d217243fbc0847b2069c6aa9db5a6897

See more details on using hashes here.

File details

Details for the file pokebase-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: pokebase-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.10

File hashes

Hashes for pokebase-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a5881566bfaa6f9a860b847be0a648f23b02babdaf79ab96f6a6d0295b497c34
MD5 025fbb26605bbc139f023322a36ae6b7
BLAKE2b-256 29c750816d1654e82cbe3e8fafcece94f5b45a584ab01d8f86c36e7c43c7e955

See more details on using hashes here.

Supported by

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