A FastAPI-powered RESTful API for querying Pokémon data.
- Asynchronous SQLAlchemy for database operations
- Pydantic models for serialization
- Customizable logging configuration, including SQLAlchemy query logging
- Python 3.7 or higher
- PostgreSQL database (with credentials)
- Clone the repository:
git clone https://github.com/jeevandhakal/pokemon.git cd pokemon
- Create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
- Install the project dependencies:
pip install -r requirements.txt
- Create a PostgreSQL database and update the database URL in
.env
:DATABASE_URL=postgresql+asyncpg://username:password@localhost/database_name DEBUG=True
- Run the Uvicorn server:
make serve
- Access the API at
http://localhost:8000/docs
for interactive documentation.
- GET
/pokemons/
- Retrieve a list of Pokémon.
- Query parameters:
limit
(int, optional): Limit the number of results.offset
(int, optional): Offset the results.type
(string, optional): Filter Pokémon by type.name
(string, optional): Filter Pokémon by name.
- Use
curl
to make a request with query parameters:
curl -X GET "http://localhost:8000/pokemons/?limit=10&offset=0&type=electric&name=pikachu"