Skip to content

unstoppableayush/fastapi-imagekit-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI Tutorial API

Simple FastAPI service with JWT auth, user management, and image upload via ImageKit. Uses async SQLAlchemy with SQLite.

Requirements

  • Python 3.10+
  • ImageKit account (for /upload)

Setup

  1. Create and activate a virtual environment.
  2. Install dependencies:
pip install .

If you use uv, run uv sync instead.

  1. Create a .env file in the project root:
IMAGEKIT_PRIVATE_KEY=your_private_key
IMAGEKIT_URL_ENDPOINT=https://ik.imagekit.io/your_account

Run

python main.py

The API starts at http://127.0.0.1:8000. Open docs at http://127.0.0.1:8000/docs.

Database

SQLite file: test.db (created on startup). Tables are created automatically at app startup.

Key Endpoints

  • POST /auth/jwt/login - login and receive JWT
  • POST /auth/register - register a user
  • POST /auth/forgot-password - request password reset
  • POST /auth/request-verify-token - request verification
  • GET /users - list users (auth required)
  • POST /upload - upload file + caption (ImageKit + DB record)
  • GET /posts - list posts
  • DELETE /posts/{post_id} - delete post

Upload Example

curl -X POST "http://127.0.0.1:8000/upload" \
	-H "Authorization: Bearer <JWT>" \
	-F "caption=Hello" \
	-F "file=@/path/to/image.jpg"

Notes

  • JWT secret is hardcoded in app/users.py for tutorial use only.
  • Image uploads require valid ImageKit credentials.

About

Simple FastAPI service with JWT auth, user management, and image upload via ImageKit. Uses async SQLAlchemy with SQLite.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages