Skip to content

API Reference

Laith edited this page May 25, 2026 · 1 revision

API Reference

Base URL: /api/v1
Auth: HTTP-only cookie auth_token (set by /signin). Send credentials: "include" on all requests.
Responses: JSON. Keys are snake_case from the server; apiClient.ts converts to camelCase automatically for the frontend.
Errors: { "detail": "message" } with standard HTTP status codes.


Authentication

POST /signup

Create a new account. Restricted to @post.jce.ac.il email domain.

Body:

{
  "username": "Laith Mimi",
  "email": "laith@post.jce.ac.il",
  "password": "SecurePass1!",
  "password_confirm": "SecurePass1!",
  "major_id": "uuid"
}

Password policy: ≥8 chars, 1 uppercase, 1 number, 1 special character.

Response: 200User object. Email verification email sent by Auth0.


POST /signin

Sign in. Sets the auth_token HttpOnly cookie.

Body:

{ "email": "...", "password": "...", "remember_me": false }

remember_me: true extends cookie lifetime to 30 days (default: 24h).

Response: 200{ "user": User }
Errors: 401 wrong password / 403 email not verified / 404 account not found


POST /signout

Clears the auth_token cookie.

Response: 200{ "message": "Logged out successfully" }


POST /forgot-password

Triggers Auth0 password reset email. Always returns success (prevents email enumeration).

Body: { "email": "..." }

Response: 200 — generic success message


GET /me

Returns the current user's profile derived from the JWT cookie. Used by the frontend boot reconciliation to verify role server-side.

Response: 200User
Errors: 401 no cookie / 403 user not in local DB


Catalog (all require auth)

GET /majors

Returns all majors. Cached indefinitely in frontend.

GET /types

Returns all material types (Slides, Exam, Lecture Notes, etc.).

GET /years

Returns static year labels: [{ id: "1", label: "Freshman (Year 1)" }, ...]

GET /semesters

Returns static semester labels.

GET /courses

Query params: major_id (UUID), year_id (int), query (string)

Returns matching courses. Requires auth.

GET /courses/{course_id}

Single course. Returns 404 if not found.

GET /lecturers

Query param: course_id (optional; currently returns all regardless)


Files (all require auth)

GET /files

Query params: course_id, type_id, lecturer_id, search

Returns approved materials. Empty array if course_id not provided.

GET /files/{file_id}

Returns file metadata + a 15-minute GCS signed download_url.

GET /files/{file_id}/stream

Streams raw PDF bytes via GCS proxy. Used by the PDF viewer.


File Upload (requires auth)

POST /courses/{course_id}/upload

Content-Type: multipart/form-data

Field Type Required
title string Yes
academic_year int (1–4) Yes
material_year int (e.g. 2023) Yes
type_id UUID Yes
lecturer_id UUID Yes
notes string No
file binary Yes

Clone this wiki locally