Demo Video 📽️: https://www.youtube.com/watch?v=DXXRnLPZq_8
This project is a RESTful API developed with FastAPI that provides detailed data on over 1,000 Pokémon. It allows users to query various Pokémon attributes such as name, species, abilities, type, and combat stats. The API integrates a PostgreSQL database to store and manage Pokémon data scraped from external sources.
-
Comprehensive Pokémon Data:
- Data scraped from pokemondb.net for 1,015 Pokémon.
- Data stored in CSV files and imported into a PostgreSQL database for persistence.
- Uploaded to Kaggle as an open-source dataset, receiving over 1,100 downloads and 5,000 views.
-
API Endpoints:
- Query Pokémon by different attributes such as name, abilities, type, size, species, growth rate, catch rate, friendship, and experience.
-
Automated Workflows:
- GitHub Actions configured for Continuous Integration (CI) to automate linting with Pylint and building the application inside a container.
- Python: Core programming language for developing the API and scraping Pokémon data.
- FastAPI: Framework used to build the RESTful API server.
- PostgreSQL: Relational database for storing Pokémon data.
- Scrapy: For scraping Pokémon data from external sources.
- GitHub Actions: Automates linting and container builds.
The dataset contains information about:
- Pokémon Name
- Species
- Type(s)
- Abilities
- Base Stats (HP, Attack, Defense, etc.)
- Size (Height, Weight)
- Growth Rate
- Catch Rate
- Base Friendship
- Base Experience
The dataset has been uploaded on Kaggle.
-
Clone the repository:
git clone https://github.com/capybara-brain346/pokedex-api.git cd pokedex-api
-
Set up a virtual environment (optional but recommended):
python3 -m venv venv source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Run the FastAPI server:
uvicorn app.main:app --reload
-
Access the API:
- Once the server is running, navigate to
http://127.0.0.1:8000
to access the API. - Use the interactive API documentation provided by FastAPI at
http://127.0.0.1:8000/docs
.
- Once the server is running, navigate to
To run the API using Docker:
-
Build the Docker image:
docker build -t pokedex-api .
-
Run the Docker container:
docker run -p 8080:8080 pokedex-api
-
Access the API:
- Once the container is running, navigate to
http://127.0.0.1:8080
to access the API.
- Once the container is running, navigate to
-
GET /pokemons/name/{name}:
Fetch Pokémon data by name. -
GET /pokemons/abilities/{abilities}:
Query Pokémon by their abilities. -
GET /pokemons/type/{pokemon_type}:
Query Pokémon by their type (e.g., Water, Fire, etc.). -
GET /pokemons/size:
Query Pokémon by size (height and/or weight). Pass values like>2.5
for height or<=50
for weight. -
GET /pokemons/species/{pokemon_species}:
Query Pokémon by species. -
GET /pokemons/growth_rate/{pokemon_growth_rate}:
Query Pokémon by growth rate (e.g., Fast, Slow). -
GET /pokemons/catch_rate:
Query Pokémon by catch rate. Pass values like>=45
. -
GET /pokemons/base_friendship:
Query Pokémon by base friendship. Pass values like>=50
. -
GET /pokemons/base_experience:
Query Pokémon by base experience. Pass values like>=100
.
The project utilizes GitHub Actions for automating:
- Linting: Pylint is used to maintain code quality.
- Containerization: GitHub Actions automatically builds the app inside a container for deployment.
- Add more nuanced filtering options (e.g., multi-type filtering, ability combinations).
- Implement caching for frequently queried data to improve response time.
- Add support for more detailed Pokémon statistics and movesets.