Files
citrus-cms/resources/views/guide/dashboard-stats-api.md
T
2026-04-28 21:15:09 +03:00

2.4 KiB
Raw Blame History

Dashboard Stats API Usage Guide / Dashboard İstatistikleri API Kullanım Kılavuzu

This guide details how to use the Dashboard Stats API endpoint (/api/stats/dashboard-stats). Bu kılavuz, Dashboard İstatistikleri API uç noktasının (/api/stats/dashboard-stats) nasıl kullanılacağını detaylandırır.


1. Endpoint Structure / Uç Nokta Yapısı

URL: GET /api/stats/dashboard-stats Security / Güvenlik: Static Hash (X-Api-Hash)

This endpoint is protected by a static hash instead of standard User Authentication (Bearer Token). Bu uç nokta, standart Kullanıcı Kimlik Doğrulaması (Bearer Token) yerine statik bir hash ile korunmaktadır.

Headers / Başlıklar

Header Value / Değer Required / Zorunlu Description / Açıklama
X-Api-Hash String Yes / Evet The static API hash defined in .env (API_STATIC_HASH). / .env dosyasında tanımlanan statik API anahtarı.
Accept application/json No / Hayır Recommended for JSON response. / JSON yanıtı için önerilir.

2. Response Structure / Yanıt Yapısı

The endpoint returns aggregated statistics for the project dashboard. Uç nokta, proje panosu için toplanmış istatistikleri döndürür.

{
  "status": "success",
  "data": {
    "wdi_monthly": [
        { "month": "2023-10", "shop": 150, "field": 200, "total": 350 },
        ...
    ],
    "spool_progress": {
        "On Going": 15,
        "Completed": 45,
        ...
    },
    "ndt_backlog": {
        "RT": 5,
        "UT": 2
    },
    "handover_status": { ... },
    "welding_equipment": { ... }
  }
}

3. Example Usage / Örnek Kullanım

cURL

curl -X GET "https://your-domain.com/api/stats/dashboard-stats" \
  -H "X-Api-Hash: YOUR_SECRET_HASH_KEY" \
  -H "Accept: application/json"

JavaScript (Fetch)

fetch('https://your-domain.com/api/stats/dashboard-stats', {
    method: 'GET',
    headers: {
        'Accept': 'application/json',
        'X-Api-Hash': 'YOUR_SECRET_HASH_KEY'
    }
})
.then(response => {
    if (!response.ok) throw new Error('Unauthorized');
    return response.json();
})
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

Configuration / Yapılandırma

Ensure the hash is set in your .env file: Hash anahtarının .env dosyanızda ayarlandığından emin olun:

API_STATIC_HASH=your-secure-hash-key-here