Skip to content

Repository files navigation

Airport API

A REST API for an airport booking system. It allows users to browse flights and create orders with multiple tickets. Authentication is implemented with JWT, so each user can access only their own orders and tickets.

Features

  • User registration and JWT authentication (access/refresh)
  • Flights listing
  • Create an order with multiple tickets in one request
  • Validation:
    • order cannot be created without tickets
    • seat/row must be within airplane capacity
    • prevents double-booking: unique constraint on (flight, row, seat)

Permissions

  • Unauthenticated users: read-only access to public resources (e.g. flights/routes/airplanes).
  • Authenticated users: read-only access to public resources + can create and view only their own orders/tickets.
  • Admin/Staff: full CRUD for public resources; orders/tickets remain owner-scoped (cannot view other users’ orders/tickets).

Usage

Auth

  1. Register
    • POST /api/user/register/
  2. Get token
    • POST /api/user/token/
  3. Use access token in requests:
    • Authorization: Bearer <access>

Main endpoints

  • Flights
    • GET /api/airport/flights/
  • Orders
    • GET /api/airport/orders/ (only current user)
    • POST /api/airport/orders/ (create order with tickets)
  • Tickets
    • GET /api/airport/tickets/ (only current user)
    • GET /api/airport/tickets/{id}/

Run locally

git clone https://github.com/anastasiiaoshega513/airport-api.git
cd airport-api

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python manage.py migrate
python manage.py runserver

Get token

POST /api/user/token/

{
  "email": "your_email@example.com",
  "password": "your_password"
}

Run with Docker

This project can be run locally using Docker (Django + PostgreSQL).

docker compose up --build

Postman

This repository includes ready-to-use Postman files:

Link to deployed project

Project

About

REST API for an airport booking system built with Django REST Framework. Supports flights, ticket reservations, JWT authentication, user-specific orders, seat validation, and double-booking protection.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages