Güvenlik Merkezi için public developer kullanım alanı.
Bu sayfa uzak sitelerin, backend servislerinin, local asistanların ve otomasyon araçlarının MEDPOV Güvenlik Merkezi API’sini nasıl çağıracağını gösterir. API; güvenlik olaylarını sorgulama, IP profili çıkarma, canlı trafik izleme, sistem sağlığı alma ve yetkili POST aksiyonları çalıştırma için tasarlanmıştır.
docs/openapi.yaml (20 declared GET actions). Narrative examples below add usage guidance to that canonical contract.Auth ve bağlantı standardı
API anahtarını Ayarlar sayfasındaki Remote API Access alanından oluştur. Anahtar sadece oluşturulduğu anda düz metin görünür; sonrasında hash olarak saklanır.
Önerilen header
Authorization: Bearer mpsec_YOUR_API_KEY
X-MEDPOV-Site-ID: site_xxxxxxxxx
Accept: application/jsonAlternatif olarak X-MEDPOV-API-Key: mpsec_YOUR_API_KEY veya X-API-Key kullanılabilir. Query-string API anahtarı kalıcı olarak devre dışıdır.
HTTP ve response kuralları
- Tüm cevaplar application/json; charset=utf-8 döner.
- GET aksiyonları bilgi okur; POST aksiyonları IP kuralı veya olay durumu değiştirir.
- CORS deny-by-default çalışır: Origin içeren tarayıcı çağrıları yalnızca allowed_origins listesindeyse kabul edilir; native/server istemcileri Origin göndermeden çağırabilir.
- Başarılı cevaplarda çoğunlukla tamam: true, hata durumlarında tamam: false döner.
Multi-Site Flow
GET action=sites— authenticate globally; omit the site header.- Select the returned
site_...identity. - Send
X-MEDPOV-Site-IDon every site-scoped read, analyze and write request. - Use
GET action=all-sites-overviewfor the global fleet view; omit the site header.
curl 'https://guard.medpov.com/admin/api/remote-access.php?action=sites' \
-H 'Authorization: Bearer mpsec_YOUR_API_KEY'
curl 'https://guard.medpov.com/admin/api/remote-access.php?action=all-sites-overview' \
-H 'Authorization: Bearer mpsec_YOUR_API_KEY'Sorgulanabilir komutlar
Bu aksiyonlar uzak sistemden veya local asistandan çağrılabilir. Okuma aksiyonları GET ile çalışır.
Harita erişimi ve Friday harita komutları
Harita endpoint, admin dashboard’daki Global Tehdit Haritası ile aynı mantıkta çalışır. Friday; saldırı lokasyonlarını, canlı kullanıcı noktalarını, hedefe giden iz çizgilerini ve tıklama popup alanlarını bu JSON üzerinden okuyabilir.
Harita mode seçenekleri
GET action=map&mode=threat&threat_range=24hSadece saldırı lokasyonları, threat markerları, saldırı iz çizgileri ve threat popup alanları.GET action=map&mode=live&live_range=liveAktif heartbeat ziyaretçileri, live markerları, kullanıcı iz çizgileri ve live popup alanları.GET action=map&mode=both&live_range=liveTehdit ve Live katmanları aynı harita cevabında beraber aktif gelir.GET action=both-map&include_curve_points=1Kısa alias; Friday çizgi eğrilerini curve_points ile bire bir yeniden çizebilir.GET action=map&mode=both&include_curve_points=0Daha hafif cevap; çizgi için from/to + style gelir, eğri noktaları gönderilmez.{
"ok": true,
"access": "map-intelligence",
"mode": "both",
"target": { "lat": 41.0082, "lng": 28.9784, "label": "Protected Origin" },
"threat_events": [],
"live_users": [],
"layers": {
"threat": { "enabled": true, "points": [], "traces": [], "popups": [] },
"live": { "enabled": true, "points": [], "traces": [], "popups": [] }
},
"map": {
"provider": "leaflet",
"tile_provider": "openstreetmap",
"tile_url": "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
"active_layers": ["threat", "live"],
"popup_contract": {}
}
}Yetkili POST aksiyonları
Bu komutlar sistemde değişiklik yapar. Sadece güvenilir backend, local assistant veya otomasyon servisinden çağrılmalıdır.
Uzak siteden çağırma örnekleri
Endpoint sabit kalır; sadece action ve parametreler değişir. Aşağıdaki kodlarda mpsec_YOUR_API_KEY yerine Ayarlar üzerinden üretilen anahtar kullanılmalı.
curl -X GET 'https://guard.medpov.com/admin/api/remote-access.php?action=overview' \
-H 'Authorization: Bearer mpsec_YOUR_API_KEY' \
-H 'X-MEDPOV-Site-ID: site_xxxxxxxxx'
-H 'Accept: application/json'curl -X GET 'https://guard.medpov.com/admin/api/remote-access.php?action=both-map&limit=500' \
+ -H 'Authorization: Bearer mpsec_YOUR_API_KEY' \
+ -H 'X-MEDPOV-Site-ID: site_xxxxxxxxx'
-H 'Accept: application/json'curl -X POST 'https://guard.medpov.com/admin/api/remote-access.php?action=block-ip' \
-H 'Authorization: Bearer mpsec_YOUR_API_KEY' \
-H 'X-MEDPOV-Site-ID: site_xxxxxxxxx'
-H 'Content-Type: application/json' \
-d '{"ip":"203.0.113.45","minutes":1440,"reason":"Remote confirmed abusive traffic"}'<?php
function medpov_security_api(string $endpoint, string $apiKey, string $siteId, string $action, array $params = [], string $method = 'GET'): array
{
$method = strtoupper($method);
$url = $endpoint . '?action=' . rawurlencode($action);
$headers = [
'Authorization: Bearer ' . $apiKey,
'Accept: application/json',
];
if ($siteId !== '') $headers[] = 'X-MEDPOV-Site-ID: ' . $siteId;
$body = null;
if ($method === 'GET' && $params) {
$url .= '&' . http_build_query($params);
} elseif ($params) {
$headers[] = 'Content-Type: application/json';
$body = json_encode($params, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_TIMEOUT => 20,
CURLOPT_CONNECTTIMEOUT => 8,
]);
if ($body !== null) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
}
$raw = curl_exec($ch);
$error = curl_error($ch);
$status = (int)curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);
if ($raw === false || $raw === '') {
return ['ok' => false, 'status' => $status, 'message' => $error ?: 'Empty API response'];
}
$json = json_decode($raw, true);
if (!is_array($json)) {
return ['ok' => false, 'status' => $status, 'message' => 'Invalid JSON response', 'raw' => $raw];
}
$json['_http_status'] = $status;
return $json;
}
$endpoint = 'https://example.com/security-center/admin/api/remote-access.php';
$apiKey = 'mpsec_YOUR_API_KEY';
$siteId = 'site_xxxxxxxxx'; // Discover with GET action=sites (without this header).
$overview = medpov_security_api($endpoint, $apiKey, $siteId, 'overview');
$ipProfile = medpov_security_api($endpoint, $apiKey, $siteId, 'ip-profile', ['ip' => '8.8.8.8', 'refresh' => 1]);
$block = medpov_security_api($endpoint, $apiKey, $siteId, 'block-ip', [
'ip' => '203.0.113.45',
'minutes' => 1440,
'reason' => 'Remote confirmed abusive traffic',
], 'POST');const endpoint = 'https://example.com/security-center/admin/api/remote-access.php';
const apiKey = process.env.MEDPOV_SECURITY_API_KEY;
const siteId = process.env.MEDPOV_SECURITY_SITE_ID;
async function securityApi(action, params = {}, method = 'GET') {
const url = new URL(endpoint);
url.searchParams.set('action', action);
const options = {
method,
headers: {
Authorization: `Bearer ${apiKey}`,
Accept: 'application/json'
}
};
if (siteId) options.headers['X-MEDPOV-Site-ID'] = siteId;
if (method === 'GET') {
Object.entries(params).forEach(([key, value]) => url.searchParams.set(key, String(value)));
} else {
options.headers['Content-Type'] = 'application/json';
options.body = JSON.stringify(params);
}
const res = await fetch(url, options);
const data = await res.json();
if (!res.ok || data.ok === false) throw new Error(data.message || `API error ${res.status}`);
return data;
}
const overview = await securityApi('overview');
const mapBoth = await securityApi('map', { mode: 'both', live_range: 'live', include_curve_points: 1 });
const critical = await securityApi('events', { risk: 'CRITICAL', resolved: 0, limit: 20 });Örnek cevap formatı
Her aksiyon kendi detay alanlarını döndürür; ortak başarı/hata mantığı aşağıdaki gibidir.
{
"ok": true,
"scope": "protected_site",
"version": "9.0.0",
"site": {
"id": "site_xxxxxxxxx",
"name": "Example",
"domain": "example.com"
}
}{
"ok": true,
"access": "map-intelligence",
"mode": "both",
"target": { "lat": 41.0082, "lng": 28.9784, "label": "Protected Origin" },
"threat_events": [],
"live_users": [],
"layers": {
"threat": { "enabled": true, "points": [], "traces": [], "popups": [] },
"live": { "enabled": true, "points": [], "traces": [], "popups": [] }
},
"map": {
"provider": "leaflet",
"tile_provider": "openstreetmap",
"tile_url": "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
"active_layers": ["threat", "live"],
"popup_contract": {}
}
}{
"ok": false,
"message": "Unauthorized",
"hint": "Send Authorization: Bearer <api-key> or X-MEDPOV-API-Key."
}Local assistant / otomasyon komut eşlemesi
Friday veya benzeri local asistan, kullanıcı komutunu aşağıdaki API aksiyonlarına çevirebilir.
GET action=overviewGET action=events&risk=CRITICAL&resolved=0&limit=20GET action=threat-map&threat_range=24hGET action=live-map&live_range=liveGET action=both-map&live_range=live&include_curve_points=1GET action=ip-profile&ip=8.8.8.8&refresh=1GET action=event&id=123POST action=block-ip body: ip, minutes=1440, reasonPOST action=resolve-ip-events body: ip, status=remote_ip_resolvedGET action=healthGüvenli kullanım
API key’i sadece server-side ortam değişkeninde sakla. Anahtar sızarsa Ayarlar üzerinden devre dışı bırakıp yenisini oluştur.
Rate ve timeout
Uzak helper tarafında 8-20 saniye timeout, kısa süreli cache ve kontrollü retry kullan. Sonsuz döngüyle health/overview çağırma.
Önerilen akış
Önce ping, sonra overview, riskli durumda olay veya ip-profile, en sonda gerekirse POST aksiyonları.
https://guard.medpov.com/developer-api.php. API endpoint ise https://guard.medpov.com/admin/api/remote-access.php.