Skip to content

Gio85/star-wars-api

Repository files navigation

███████╗████████╗ █████╗ ██████╗     ██╗    ██╗ █████╗ ██████╗ ███████╗     █████╗ ██████╗ ██╗
██╔════╝╚══██╔══╝██╔══██╗██╔══██╗    ██║    ██║██╔══██╗██╔══██╗██╔════╝    ██╔══██╗██╔══██╗██║
███████╗   ██║   ███████║██████╔╝    ██║ █╗ ██║███████║██████╔╝███████╗    ███████║██████╔╝██║
╚════██║   ██║   ██╔══██║██╔══██╗    ██║███╗██║██╔══██║██╔══██╗╚════██║    ██╔══██║██╔═══╝ ██║
███████║   ██║   ██║  ██║██║  ██║    ╚███╔███╔╝██║  ██║██║  ██║███████║    ██║  ██║██║     ██║
╚══════╝   ╚═╝   ╚═╝  ╚═╝╚═╝  ╚═╝     ╚══╝╚══╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝    ╚═╝  ╚═╝╚═╝     ╚═╝
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄

NestJS TypeScript PostgreSQL TypeORM Swagger Render Supabase npm Node.js

A fully self-contained Star Wars REST API backed by PostgreSQL.

🚀 Live API: https://star-wars-api-9o3y.onrender.com 📖 Swagger Docs: https://star-wars-api-9o3y.onrender.com/api/docs


🗂️ Project Structure

star-wars-api/
├── apps/
│   └── api/              🚀 NestJS REST API
└── packages/
    └── types/            📐 Shared TypeScript interfaces

✨ Features

  • 🎬 11 films — Episodes I–IX, Rogue One & Solo
  • 👤 101 characters — from Luke Skywalker to Grogu
  • 🪐 62 planets — Tatooine to Exegol
  • 🧬 40 species — Human to Ewok to Dathomirian
  • 🚀 32 starships — Millennium Falcon to the Supremacy
  • 🚗 30 vehicles — AT-AT to Podracer
  • 🔍 Cross-resource search — query across all resources at once
  • 📄 Pagination & filtering on every endpoint
  • 📖 Swagger docs at /api/docs

🌐 API Examples

Pagination

# Page 1, 10 results per page (default)
GET https://star-wars-api-9o3y.onrender.com/characters

# Page 2, 20 results per page
GET https://star-wars-api-9o3y.onrender.com/characters?page=2&limit=20

# First 5 films
GET https://star-wars-api-9o3y.onrender.com/films?page=1&limit=5

Filtering

# Search characters by name
GET https://star-wars-api-9o3y.onrender.com/characters?name=Luke

# Filter planets by climate
GET https://star-wars-api-9o3y.onrender.com/planets?climate=arid

# Filter starships by class
GET https://star-wars-api-9o3y.onrender.com/starships?starshipClass=Star+Destroyer

# Combine filters with pagination
GET https://star-wars-api-9o3y.onrender.com/characters?name=sky&page=1&limit=5

Single Resource

# Get a character by ID
GET https://star-wars-api-9o3y.onrender.com/characters/1

# Get a film with full cast & relations
GET https://star-wars-api-9o3y.onrender.com/films/4

# Get a planet by ID
GET https://star-wars-api-9o3y.onrender.com/planets/1

Cross-resource Search

# Search across all resources
GET https://star-wars-api-9o3y.onrender.com/search?q=Skywalker

# Search within a specific resource
GET https://star-wars-api-9o3y.onrender.com/search?q=Falcon&type=starships

Response Format

{
  "data": [...],
  "meta": {
    "total": 101,
    "page": 1,
    "limit": 10,
    "totalPages": 11
  }
}

🚀 Getting Started (Local)

Prerequisites

  • Node.js 20+
  • npm
  • A PostgreSQL database (Supabase free tier works great)

1. Install dependencies

npm install --prefix apps/api

2. Configure environment

cp apps/api/.env.example apps/api/.env

Fill in your database credentials:

DB_HOST=your-db-host
DB_PORT=5432
DB_NAME=your-db-name
DB_USER=your-db-user
DB_PASS=your-db-password
PORT=3000
NODE_ENV=development

3. Start the API

npm run dev --prefix apps/api

4. Seed the database

npm run seed --prefix apps/api

The API is now live at http://localhost:3000 🎉 Swagger docs at http://localhost:3000/api/docs 📖


🌐 API Endpoints

Method Endpoint Description
GET /characters List all characters
GET /characters/:id Get a character by ID
GET /films List all films
GET /films/:id Get a film with full cast & relations
GET /planets List all planets
GET /planets/:id Get a planet by ID
GET /species List all species
GET /species/:id Get a species by ID
GET /starships List all starships
GET /starships/:id Get a starship by ID
GET /vehicles List all vehicles
GET /vehicles/:id Get a vehicle by ID
GET /search?q= Search across all resources

Query Parameters

All list endpoints support:

Param Type Description
page number Page number (default: 1)
limit number Results per page (default: 10, max: 100)
name string Filter by name (case-insensitive)

🛠️ Development

# Start API in watch mode
npm run dev --prefix apps/api

# Build API
npm run build:api

# Run tests
npm run test --prefix apps/api

# Re-seed the database
npm run seed --prefix apps/api

🏗️ Tech Stack

Layer Technology
API Framework NestJS
Database ORM TypeORM
Database PostgreSQL
Hosting Render
API Docs Swagger / OpenAPI
Package Manager npm
Language TypeScript

📁 Data Coverage

Resource Count Eras Covered
🎬 Films 11 Episodes I–IX, Rogue One, Solo
👤 Characters 101 Prequel, Original, Sequel, Mandalorian
🪐 Planets 62 All eras
🧬 Species 40 All eras
🚀 Starships 32 All eras
🚗 Vehicles 30 All eras

📜 License

MIT

About

A free & open Star Wars REST API — characters, films, planets, species, starships & vehicles.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages