Adding clean install to repo with project files

This commit is contained in:
AmariBolmer
2024-10-21 18:07:45 -07:00
commit 5fb3049888
15 changed files with 183 additions and 0 deletions

28
example_usage_api.py Normal file
View File

@@ -0,0 +1,28 @@
# example_usage.py
from poke_sdk.PokeAPI import PokeAPI
def main():
# Create an instance of the PokeAPI class
api = PokeAPI()
# Fetch a Pokémon by name
try:
pikachu = api.get_pokemon("pikachu")
print(f"Retrieved Pokémon: {pikachu.name}")
print(f"ID: {pikachu.id}")
print(f"Types: {', '.join(pikachu.types)}")
except Exception as e:
print(f"An error occurred while fetching Pokémon: {e}")
# Fetch a generation by ID
try:
generation = api.get_generation("1")
print(f"Retrieved Generation: {generation.name}")
print(f"ID: {generation.id}")
print(f"Pokémon Species in this Generation: {', '.join(generation.pokemon_species)}")
except Exception as e:
print(f"An error occurred while fetching generation: {e}")
if __name__ == "__main__":
main()