Skip to content

API Overview

The REST API runs on Fastify 5 at port 3001.

Authentication

JWT tokens in httpOnly cookies. Include credentials: "include" in fetch requests.

Protected endpoints require the token cookie or Authorization: Bearer <token> header.

Response Format

All endpoints return JSON. List endpoints include pagination:

json
{
  "listings": [...],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 156,
    "totalPages": 8
  }
}

Error Format

json
{
  "error": "Error message"
}

Endpoints Summary

Public (no auth)

MethodPathDescription
GET/healthHealth check
GET/listingsBrowse listings with filters + pagination
GET/listings/:idListing detail with images
GET/listings/:id/similarSimilar listings (scored by bedrooms, price, distance)
GET/neighborhoodsList neighborhoods
GET/neighborhoods/:slugNeighborhood profile with stats
GET/articlesList published articles (blog/wiki)
GET/articles/:slugGet single published article
GET/postal-areasList all FSAs with listing stats + boundaries
GET/postal-areas/:fsaFSA detail with boundary, listings, nested postal codes
GET/postal-areas/code/:codeFull 6-digit postal code detail with listings
GET/census-tractsAll census tracts with boundaries + income data
GET/census-tracts/:ctuidSingle census tract by CTUID
GET/income/snapshotsIncome snapshots (filterable by geo_type, source, year)
GET/income/fsa-trendsCRA FSA income trends 2015-2021
GET/income/ct-comparison2016 vs 2021 CT income change (923 matched CTs)
GET/income/distributionIncome bracket distributions (19 brackets, 2016+2021)
GET/income/rent-trendsCMHC avg rent by zone over time (optional geo_code filter)
POST/auth/registerRegister user
POST/auth/loginLogin (sets cookie)
POST/auth/logoutLogout (clears cookie)
POST/inquiriesSubmit inquiry (name + email + message)

Authenticated (any user)

MethodPathDescription
GET/auth/meCurrent user
PUT/auth/profileUpdate name and phone
PUT/auth/passwordChange password
GET/favoritesUser's saved listings
GET/favorites/checkCheck which listings are favorited
POST/favoritesSave a listing
DELETE/favorites/:listingIdRemove favorite
GET/inquiries/myUser's sent inquiries

Landlord

MethodPathDescription
GET/listings/myLandlord's own listings
POST/listingsCreate listing
PUT/listings/:idUpdate listing (owner)
PATCH/listings/:id/statusChange status (owner)
DELETE/listings/:idDelete listing (owner)
POST/listings/:id/imagesUpload images (owner)
DELETE/listings/:id/images/:imageIdDelete image (owner)
PATCH/listings/:id/images/:imageIdSet primary image (owner)
GET/listings/:id/notesList notes (owner)
POST/listings/:id/notesAdd note (owner)
PUT/listings/:id/notes/:noteIdEdit note (owner)
DELETE/listings/:id/notes/:noteIdDelete note (owner)
GET/inquiries/listing/:idInquiries for a listing (owner)
POST/claimsSubmit claim for scraped listing
GET/claims/myLandlord's claims