Skip to content

FastAPI-powered Pokémon REST API with async SQLAlchemy, Pydantic models, and logging configuration for querying Pokémon data.

License

Notifications You must be signed in to change notification settings

jeevandhakal/pokemon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pokémon API

Overview

A FastAPI-powered RESTful API for querying Pokémon data.

Features

  • Asynchronous SQLAlchemy for database operations
  • Pydantic models for serialization
  • Customizable logging configuration, including SQLAlchemy query logging

Setup Instructions

Prerequisites

  • Python 3.7 or higher
  • PostgreSQL database (with credentials)

Installation

  1. Clone the repository:
    git clone https://github.com/jeevandhakal/pokemon.git
    cd pokemon
  2. Create a virtual environment (recommended):
    python -m venv venv
    source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
  3. Install the project dependencies:
    pip install -r requirements.txt
  4. Create a PostgreSQL database and update the database URL in .env:
    DATABASE_URL=postgresql+asyncpg://username:password@localhost/database_name
    DEBUG=True
  5. Run the Uvicorn server:
    make serve
  6. Access the API at http://localhost:8000/docs for interactive documentation.

Usage

List Pokémon

  • 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.

Example API Request

  • Use curl to make a request with query parameters:

List Pokémon (with filtering)

curl -X GET "http://localhost:8000/pokemons/?limit=10&offset=0&type=electric&name=pikachu"

About

FastAPI-powered Pokémon REST API with async SQLAlchemy, Pydantic models, and logging configuration for querying Pokémon data.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published