AIA API Dokümantasyonu

Ulusal Afet Ağı - RESTful API ve WebSocket entegrasyon kılavuzu

Tüm endpointler JWT token ile korunmaktadır • Base URL: http://localhost:8080/api/v1
İçindekiler
POST
/api/v1/auth/login

Kullanıcı girişi ve JWT token alma

Request Body

{
  "email": "user@example.com",
  "password": "password123",
  "device_info": {
    "user_agent": "Mozilla/5.0...",
    "ip_address": "192.168.1.1"
  }
}

Response

{
  "success": true,
  "data": {
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "user": {
      "id": "usr_1234567890",
      "email": "user@example.com",
      "role": "operator",
      "permissions": [
        "devices:read",
        "devices:write",
        "incidents:read"
      ]
    }
  }
}

Önek (cURL)

curl -X POST http://localhost:8080/api/v1/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "user@example.com",
    "password": "password123"
  }'
POST
/api/v1/auth/logoutAuth Required

Oturumu kapat ve token iptal et

Request Body

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Response

{
  "success": true,
  "message": "Başarıyla çıkış yapıldı"
}

Önek (cURL)

curl -X POST http://localhost:8080/api/v1/auth/logout \
  -H "Authorization: Bearer YOUR_TOKEN"
GET
/api/v1/auth/meAuth Required

Mevcut kullanıcı bilgilerini getir

Response

{
  "success": true,
  "data": {
    "id": "usr_1234567890",
    "email": "user@example.com",
    "role": "operator",
    "permissions": [
      "devices:read",
      "devices:write"
    ],
    "created_at": "2025-01-31T10:00:00Z",
    "last_login": "2025-01-31T12:30:00Z"
  }
}

Önek (cURL)

curl -X GET http://localhost:8080/api/v1/auth/me \
  -H "Authorization: Bearer YOUR_TOKEN"

Hızlı Başlangıç

Giriş yapın ve JWT token alın
Tüm isteklerde Authorization header kullanın
WebSocket ile gerçek zamanlı verilere abone olun
Firmware işlemlerini async job olarak başlatın
Authorization: Bearer YOUR_TOKEN_HERE

HTTP Durum Kodları

200
Başarılı
201
Oluşturuldu
204
İçerik Yok
400
Geçersiz İstek
401
Yetkisiz
403
Yasaklanmış
404
Bulunamadı
500
Sunucu Hatası