---
title: "Detect Location Risk Signals — Risk & Diligence API"
description: "Stream location-risk analysis for a US address, surfacing environmental, crime, flood, and nuisance red flags before you commit capital to a purchase."
---

# Streaming location-risk analysis for a US address

`POST /api/properties/red-flags/stream/`

5 credits

## What it returns

A **Server-Sent Events stream** of location red flags for a US property: nearby places and street-level conditions that can weigh on its value. Examples are bars and liquor stores, industrial sites, airports and rail lines, cemeteries, power lines, and visible blight. Each flag carries a `name`, `flag_type`, `category`, `distance_miles`, `importance` (1–5), and `flag_score`. The final report adds `total_flags`, an `aggregate_risk_score` (0–10), and a `risk_level` (`None`, `Low`, `Moderate`, or `High`). Emits five sequential events:

1. `geocoded` — the address has been resolved to coordinates
2. `area_classified` — the area is classified as Urban, Suburban, or Rural
3. `flags_detected` — the nearby-places lookup is complete
4. `vision_analyzed` — the street-level imagery analysis is complete
5. `complete` — the final report, with every flag scored

Plus `error` if any stage fails. The `complete` event is augmented with `from_cache: true` + `cached_at` (ISO 8601 UTC, `Z` suffix) when served from cache.

## When to use it

- Render a real-time risk-analysis page where each stage animates as it loads.
- Pre-screen wholesale leads for hidden risk factors before outreach.
- Disclose neighborhood risk to buyers in a transparent format.

## Pricing

5 credits per fresh request. Cache hits (re-running the same `address`+`detection_mode` for the same user within the cache TTL) cost 0 credits and replay the full event sequence so client UIs animate identically.

## Streaming protocol

Content-Type: `text/event-stream`. Each event follows the SSE spec — `event: <name>` newline, `data: <json>` newline, blank-line separator. Errors return as `event: error`; errored runs are never persisted to cache.

## FAQ

### What if I don't want streaming?
The endpoint is streaming-only. Consume the full stream and use the `complete` event's payload as the final response.

### Why is `detection_mode` not a parameter?
The proxy forces `detection_mode: single` and ignores client-supplied values. Multi-mode is reserved for future expansion.

### How long do cached results live?
Until the cache TTL expires. Stale rows are self-purged on next lookup — no scheduled task. Cache key is per-user + sha256(normalized address).
