{"success":true,"documentation":{"title":"API Pública de Referenciales.cl - Documentación","version":"1.0.0","description":"API pública para acceder a los datos del mapa de referenciales inmobiliarias de Chile sin autenticación.","quickStart":{"description":"Comenzar en 3 pasos simples","steps":[{"step":1,"title":"Obtener datos del mapa","code":"\n// Fetch básico\nconst response = await fetch('https://referenciales.cl/api/public/map-data');\nconst { data, metadata } = await response.json();\n\n        "},{"step":2,"title":"Filtrar datos (opcional)","code":"\n// Con filtros\nconst params = new URLSearchParams({\n  comuna: 'santiago',\n  anio: '2024',\n  limit: '50'\n});\n\nconst response = await fetch(`https://referenciales.cl/api/public/map-data?${params}`);\nconst { data } = await response.json();\n        "},{"step":3,"title":"Integrar con React Leaflet","code":"\nimport React, { useEffect, useState } from 'react';\nimport { MapContainer, TileLayer, CircleMarker, Popup } from 'react-leaflet';\n\nconst ReferencialMap = () => {\n  const [mapData, setMapData] = useState([]);\n  const [loading, setLoading] = useState(true);\n\n  useEffect(() => {\n    const fetchData = async () => {\n      try {\n        const response = await fetch('https://referenciales.cl/api/public/map-data');\n        const { data, metadata } = await response.json();\n        setMapData(data);\n      } catch (error) {\n        console.error('Error:', error);\n      } finally {\n        setLoading(false);\n      }\n    };\n\n    fetchData();\n  }, []);\n\n  if (loading) return <div>Cargando mapa...</div>;\n\n  return (\n    <MapContainer \n      center={[-33.4489, -70.6693]} \n      zoom={10} \n      style={{ height: '500px', width: '100%' }}\n    >\n      <TileLayer\n        url=\"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png\"\n        attribution='&copy; OpenStreetMap contributors'\n      />\n      {mapData.map(point => (\n        <CircleMarker\n          key={point.id}\n          center={[point.lat, point.lng]}\n          radius={20}\n          fillOpacity={0.7}\n        >\n          <Popup>\n            <div>\n              <h3>{point.predio || 'Predio sin nombre'}</h3>\n              <p><strong>Comuna:</strong> {point.comuna}</p>\n              <p><strong>CBR:</strong> {point.cbr}</p>\n              <p><strong>Año:</strong> {point.anio}</p>\n              <p><strong>Superficie:</strong> {point.superficie} m²</p>\n              <p><strong>Monto:</strong> {point.monto}</p>\n              {point.observaciones && (\n                <p><strong>Observaciones:</strong> {point.observaciones}</p>\n              )}\n            </div>\n          </Popup>\n        </CircleMarker>\n      ))}\n    </MapContainer>\n  );\n};\n\nexport default ReferencialMap;\n        "}]},"endpoints":{"/api/public/map-data":{"method":"GET","description":"Obtiene todos los datos del mapa de referenciales","parameters":{"comuna":"string (opcional) - Filtrar por comuna","anio":"number (opcional) - Filtrar por año","limit":"number (opcional) - Limitar número de resultados"},"response":{"success":"boolean","data":"array of MapPoint objects","metadata":"object with additional info"},"example":"https://referenciales.cl/api/public/map-data?comuna=santiago&limit=10"},"/api/public/map-config":{"method":"GET","description":"Obtiene la configuración del mapa y metadatos de la API","response":{"success":"boolean","config":"object with API configuration","timestamp":"ISO date string"},"example":"https://referenciales.cl/api/public/map-config"}},"typeDefinitions":"\n// TypeScript Types para mejor integración\n\nexport interface MapPoint {\n  id: string;\n  lat: number;\n  lng: number;\n  fojas?: string;\n  numero?: number;\n  anio?: number;\n  cbr?: string;\n  predio?: string;\n  comuna?: string;\n  rol?: string;\n  fechaescritura?: string;\n  superficie?: number;\n  monto?: string;\n  observaciones?: string;\n}\n\nexport interface MapDataResponse {\n  success: boolean;\n  data: MapPoint[];\n  metadata: {\n    total: number;\n    timestamp: string;\n    center: [number, number];\n    defaultZoom: number;\n    attribution: string;\n  };\n}\n\nexport interface MapFilters {\n  comuna?: string;\n  anio?: number;\n  limit?: number;\n}\n\n// Hook personalizado para React\nexport const useReferencialMapData = (filters?: MapFilters) => {\n  const [data, setData] = useState<MapPoint[]>([]);\n  const [loading, setLoading] = useState(true);\n  const [error, setError] = useState<string | null>(null);\n\n  useEffect(() => {\n    const fetchData = async () => {\n      try {\n        setLoading(true);\n        const params = new URLSearchParams();\n        \n        if (filters?.comuna) params.append('comuna', filters.comuna);\n        if (filters?.anio) params.append('anio', filters.anio.toString());\n        if (filters?.limit) params.append('limit', filters.limit.toString());\n\n        const url = `https://referenciales.cl/api/public/map-data?${params}`;\n        const response = await fetch(url);\n        \n        if (!response.ok) {\n          throw new Error('Error al obtener datos');\n        }\n\n        const result: MapDataResponse = await response.json();\n        setData(result.data);\n        setError(null);\n      } catch (err) {\n        setError(err instanceof Error ? err.message : 'Error desconocido');\n      } finally {\n        setLoading(false);\n      }\n    };\n\n    fetchData();\n  }, [filters?.comuna, filters?.anio, filters?.limit]);\n\n  return { data, loading, error };\n};\n  ","integration":{"nextjs":{"title":"Integración con Next.js","installation":"npm install react-leaflet leaflet","code":"\n// pages/mapa.tsx o app/mapa/page.tsx\nimport dynamic from 'next/dynamic';\n\nconst ReferencialMap = dynamic(\n  () => import('../components/ReferencialMap'),\n  { ssr: false }\n);\n\nexport default function MapaPage() {\n  return (\n    <div>\n      <h1>Mapa de Referenciales</h1>\n      <ReferencialMap />\n    </div>\n  );\n}\n      "},"react":{"title":"Integración con React (Create React App)","installation":"npm install react-leaflet leaflet @types/leaflet","additionalSetup":"\n// En tu CSS principal o component CSS\n@import \"leaflet/dist/leaflet.css\";\n\n// Configurar iconos de Leaflet (requerido)\nimport L from 'leaflet';\nimport icon from 'leaflet/dist/images/marker-icon.png';\nimport iconShadow from 'leaflet/dist/images/marker-shadow.png';\n\nlet DefaultIcon = L.icon({\n  iconUrl: icon,\n  shadowUrl: iconShadow,\n  iconSize: [25, 41],\n  iconAnchor: [12, 41]\n});\n\nL.Marker.prototype.options.icon = DefaultIcon;\n      "}},"cors":{"description":"La API está configurada con CORS abierto (*) para permitir acceso desde cualquier dominio.","headers":["Access-Control-Allow-Origin: *","Access-Control-Allow-Methods: GET, OPTIONS","Access-Control-Allow-Headers: Content-Type"]},"examples":{"vanilla":{"title":"JavaScript Vanilla","code":"\n// Obtener y mostrar datos\nfetch('https://referenciales.cl/api/public/map-data?limit=5')\n  .then(response => response.json())\n  .then(result => {\n    result.data.forEach(point => {\n      console.log(`Punto: ${point.comuna}, Monto: ${point.monto}`);\n    });\n  })\n  .catch(error => {\n    console.error('Error:', error);\n  });\n      "},"curl":{"title":"cURL","code":"\n# Obtener todos los datos\ncurl \"https://referenciales.cl/api/public/map-data\"\n\n# Con filtros\ncurl \"https://referenciales.cl/api/public/map-data?comuna=santiago&anio=2024&limit=10\"\n\n# Obtener configuración\ncurl \"https://referenciales.cl/api/public/map-config\"\n      "}},"support":{"description":"Para soporte técnico o consultas sobre la API","contact":{"website":"https://referenciales.cl","email":"Disponible en el sitio web"}}},"timestamp":"2026-04-09T02:02:12.893Z"}