{
  "openapi": "3.0.3",
  "info": {
    "title": "GeoRiskPulse Global Disaster Risk Reduction (DRR) Open API",
    "description": "Spasial Open API standar global yang mengadopsi taksonomi UNDRR (United Nations Office for Disaster Risk Reduction) dan Sendai Framework for Disaster Risk Reduction 2015–2030. Menyediakan data real-time multisumber untuk pemantauan bahaya geologi, hidrometeorologi, jaringan CCTV pemantau, dan crowdsource pelaporan warga.",
    "version": "3.0.0",
    "contact": {
      "name": "GeoRiskPulse Open Data Initiative",
      "url": "https://georiskpulse.ctar.tech",
      "email": "api@georiskpulse.ctar.tech"
    },
    "license": {
      "name": "Open Data Commons Open Database License (ODbL)",
      "url": "https://opendatacommons.org/licenses/odbl/"
    }
  },
  "servers": [
    {
      "url": "https://georiskpulse.ctar.tech/api",
      "description": "Production Vercel Global Edge Server"
    },
    {
      "url": "https://gplay.ctar.tech/api/v1",
      "description": "PostGIS High-Performance Dedicated Hub"
    },
    {
      "url": "http://localhost:8080/api",
      "description": "Local Development Server"
    }
  ],
  "tags": [
    {
      "name": "Hazards (Bahaya Spasial)",
      "description": "Data spasial bahaya gempa bumi, sesar tektonik, radar cuaca, dan anomali termal berbasis Bounding Box (BBOX)."
    },
    {
      "name": "Crowdsourcing & Reports",
      "description": "Pelaporan kejadian bencana real-time oleh warga dan instansi terakreditasi."
    },
    {
      "name": "CCTV & Webcams",
      "description": "Jaringan kamera pengawas kebencanaan visual global."
    },
    {
      "name": "Webhooks & Bots",
      "description": "Integrasi bot dua arah untuk WhatsApp dan Telegram."
    },
    {
      "name": "Authentication & National Keys",
      "description": "Pengelolaan 1 Kunci API Nasional untuk integrasi sistem B2G."
    }
  ],
  "paths": {
    "/hazards": {
      "get": {
        "tags": ["Hazards (Bahaya Spasial)"],
        "summary": "Kueri Data Bahaya Spasial Bounding Box (BBOX)",
        "description": "Mengembalikan seluruh entitas bencana (gempa bumi, deformasi tanah, hotspot api) dalam format GeoJSON FeatureCollection sesuai batas koordinat layar pengguna.",
        "parameters": [
          {
            "name": "bbox",
            "in": "query",
            "required": true,
            "description": "Koordinat batas BBOX (minLng,minLat,maxLng,maxLat). Contoh: 106.5,-7.2,108.2,-6.2",
            "schema": { "type": "string", "example": "106.5,-7.2,108.2,-6.2" }
          },
          {
            "name": "types",
            "in": "query",
            "required": false,
            "description": "Filter jenis bahaya dipisahkan koma (earthquake,flood,fire,insar)",
            "schema": { "type": "string", "example": "earthquake,flood" }
          }
        ],
        "responses": {
          "200": {
            "description": "GeoJSON FeatureCollection berhasil dikembalikan",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": { "type": "string", "example": "FeatureCollection" },
                    "features": { "type": "array", "items": { "type": "object" } },
                    "metadata": { "type": "object" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/reports": {
      "post": {
        "tags": ["Crowdsourcing & Reports"],
        "summary": "Kirim Laporan Kejadian Bencana Warga / Instansi",
        "description": "Menyimpan laporan bencana baru langsung ke tabel PostGIS dengan validasi spasial koordinat GPS.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["disaster_type", "title", "latitude", "longitude"],
                "properties": {
                  "disaster_type": { "type": "string", "enum": ["Banjir", "Gempa", "Longsor", "Retakan Tanah", "Angin Kencang", "Lainnya"] },
                  "title": { "type": "string", "example": "Luapan air sungai 80cm di jalan raya" },
                  "description": { "type": "string" },
                  "latitude": { "type": "number", "example": -6.2088 },
                  "longitude": { "type": "number", "example": 106.8456 },
                  "water_depth_cm": { "type": "integer", "example": 80 },
                  "photo_url": { "type": "string", "format": "uri" },
                  "reporter_name": { "type": "string" },
                  "reporter_phone": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Laporan berhasil dicatat",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean", "example": true },
                    "id": { "type": "integer", "example": 142 },
                    "status": { "type": "string", "example": "SUBMITTED" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/cctv/nearby": {
      "get": {
        "tags": ["CCTV & Webcams"],
        "summary": "Daftar Kamera CCTV & Webcams Berdasarkan Area",
        "parameters": [
          { "name": "minLng", "in": "query", "required": true, "schema": { "type": "number" } },
          { "name": "minLat", "in": "query", "required": true, "schema": { "type": "number" } },
          { "name": "maxLng", "in": "query", "required": true, "schema": { "type": "number" } },
          { "name": "maxLat", "in": "query", "required": true, "schema": { "type": "number" } }
        ],
        "responses": {
          "200": { "description": "Daftar kamera berhasil diambil" }
        }
      }
    },
    "/webhook": {
      "post": {
        "tags": ["Webhooks & Bots"],
        "summary": "Inbound Webhook Receiver (Telegram & WhatsApp)",
        "description": "Titik integrasi bot eksternal untuk parsing pesan, lokasi pin GPS, dan foto dari pengguna pesan instan.",
        "responses": {
          "200": { "description": "Webhook diproses dengan sukses" }
        }
      }
    },
    "/auth/keys": {
      "post": {
        "tags": ["Authentication & National Keys"],
        "summary": "Pendaftaran Kunci API Nasional Resmi",
        "description": "Menerbitkan 1 Kunci API Nasional (format: GRP-XXXX-XXXX-XXXX) untuk instansi kementerian, pemda, atau lembaga riset.",
        "responses": {
          "201": { "description": "Kunci API resmi berhasil diterbitkan" }
        }
      }
    }
  }
}
