Skip to content

tyren-r/rotj-api

Repository files navigation

SWAPI: Return of the Jedi

Python Star Wars API built with FastAPI, SQLModel, and Pydantic v2. Typed responses, richer data, and name-based routes.

Features

  • Descriptions and image URLs for every record
  • Strict typing with Pydantic v2 and SQLModel
  • Relations return names instead of URLs
  • Name-based lookup (e.g., /api/characters/luke instead of /characters/1)
  • SQLite + ORM; auto-seeds from assets/base_data on startup
  • Custom Swagger UI at /api/docs (OpenAPI at /api/openapi.json)

Tech stack

  • FastAPI, SQLModel, Pydantic v2, Uvicorn
  • SQLite (default file: pyswapi.db), Pydantic Settings for overrides
  • Dockerfile for container builds

Quickstart (local)

Prereqs: Python 3.11+ and pip.

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn main:app --reload

Configuration

  • Override defaults via environment variables matching env.py fields:
    • SQLITE_FILE_NAME (default pyswapi.db)
    • SQLITE_URL (default sqlite:///pyswapi.db)
    • IMAGES_BASE_URL (S3 base for image assets)
  • You can also use a .env file; Pydantic Settings will pick it up.

Docker

docker build -t rotj-api .
docker run -p 8000:8000 rotj-api

Testing

pytest
# or with coverage
pytest --cov=.

Routes (summary)

  • /api/characters
  • /api/movies
  • /api/planets
  • /api/species
  • /api/vehicles
  • OpenAPI schema: /api/openapi.json

About

SWAPI: Return of the Jedi - The newest version of the star wars API!

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors