mirror of
https://github.com/LukeHagar/pokemonAPI-Amari.git
synced 2025-12-10 04:21:09 +00:00
Adding clean install to repo with project files
This commit is contained in:
19
poke_sdk/api_client.py
Normal file
19
poke_sdk/api_client.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import requests
|
||||
from .exceptions import APIError
|
||||
|
||||
|
||||
class APIClient:
|
||||
BASE_URL = "https://pokeapi.co/api/v2"
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def get(self, endpoint):
|
||||
"""Send a GET request to the specified endpoint."""
|
||||
url = f"{self.BASE_URL}/{endpoint}"
|
||||
response = requests.get(url)
|
||||
|
||||
if response.status_code != 200:
|
||||
raise APIError(f"Error fetching data: {response.status_code} - {response.text}")
|
||||
|
||||
return response.json()
|
||||
Reference in New Issue
Block a user