Skip to content

midaz/sf-police-blotter

Repository files navigation

SF 911 Live Feed (Socrata → Supabase → Next.js)

This app ingests SF 911 call data from data.sfgov.org (gnap-fj3t) every minute and displays:

  • Latest 200 calls (fast)
  • Load more button for older calls
  • Realtime updates via Supabase Realtime

It can also (optionally) push new calls to Discord via a Discord Webhook from the ingest cron.

1) Create Supabase tables

In Supabase SQL Editor, run:

  • supabase/schema.sql

2) Configure env vars

Copy env.example to .env.local (Next.js convention) and fill:

  • SOCRATA_APP_TOKEN
  • NEXT_PUBLIC_SUPABASE_URL
  • NEXT_PUBLIC_SUPABASE_ANON_KEY
  • SUPABASE_SERVICE_ROLE_KEY
  • INGEST_SECRET
  • NEXT_PUBLIC_DISCORD_INVITE_URL (optional; adds a “Discord (live)” link in the UI)
  • DISCORD_WEBHOOK_URL (optional)

3) Run locally

npm install
npm run dev

4) Ingest data (manually)

curl -X POST "http://localhost:3000/api/ingest?secret=$INGEST_SECRET"

5) Vercel cron (every minute)

Create a Vercel Cron Job to hit:

  • /api/ingest?secret=YOUR_INGEST_SECRET

Run it every 1 minute.

6) Discord push (optional)

If you set DISCORD_WEBHOOK_URL, each ingest run will post up to DISCORD_MAX_POSTS_PER_INGEST calls that have not been posted yet (tracked by discord_posted_at on public.calls).

Notes:

  • Treat the webhook URL like a password: don’t commit it and rotate it if it leaks.
  • Calls with sensitive_call=true will not include map coordinates.

About

Real-time police blotter of San Francisco

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors