"""Image endpoints – retrieve photo URLs from the raw Funda data.""" from fastapi import APIRouter, Depends, HTTPException from sqlalchemy import text from sqlalchemy.orm import Session from app.config import settings from app.database import get_db router = APIRouter() @router.get("/listings/{global_id}/images") def get_listing_images( global_id: str, db: Session = Depends(get_db), ) -> dict[str, list[str]]: """Return image URLs for a listing from the raw Funda JSON data.""" row = db.execute( text( "SELECT raw_json->'photo_urls' AS photo_urls " "FROM raw_funda.listing_details " "WHERE global_id = :gid" ), {"gid": global_id}, ).first() if not row or not row.photo_urls: return {"images": []} return {"images": list(row.photo_urls)}