GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - PokeAPI/pokebase: Python 3 wrapper for Pokéapi v2

BranchesTags
Open more actions menu

Latest commit

 

History

107 Commits
107 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
pokebase
pokebase
 
 
requirements
requirements
 
 
tests
tests
 
 
.flake8
.flake8
 
 
.gitignore
.gitignore
 
 
.pre-commit-config.yaml
.pre-commit-config.yaml
 
 
LICENSE.txt
LICENSE.txt
 
 
MANIFEST.in
MANIFEST.in
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
setup.py
setup.py
 
 
tox.ini
tox.ini
 
 

Repository files navigation

Pokebase swampert

actions Python 3.6 pypi Python >=3.8 github

Warning

Currently unsupported

pokebase is a simple but powerful Python interface to the PokeAPI database

Maintainer: Nobody

Installation

Version Support

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

pokebase 1.4.1 drops support for Python 3.6 and adds support for Python >=3.8 <=3.12. Install it with pip install pokebase

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

To delete the existing cache, don't delete files directly, as shelve's file structure is platform-dependant. Indead, do

>>> from pokebase import cache
>>> cache.empty_cache() 

About

Python 3 wrapper for Pokéapi v2

Topics

hacktoberfestpokeapipythonwrapper

Resources

Readme
BSD-3-Clause license
Activity
Custom properties

Stars

364 stars

Watchers

12 watching

Forks

59 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.