Bolu Abant İzzet Baysal Üniversitesi Web Servisi

Giriş

Bu REST API web servisi, veriler veritabanındaki tablolara güvenli bir şekilde erişim sağlar. API key tabanlı kimlik doğrulama sistemi ile sadece yetkili kullanıcılar ve kurumlar verilere erişebilir.

API Versiyonu: v1
Base URL: http://webservis2.ibu.edu.tr/api/index.php?path=
Not: URL formatı: http://webservis2.ibu.edu.tr/api/index.php?path={table_name}&page=1&limit=10

Kimlik Doğrulama (Authentication)

Tüm API istekleri için geçerli bir API key gereklidir. API key'inizi aşağıdaki yöntemlerden biriyle gönderebilirsiniz:

1. Header ile (Önerilen)

X-API-Key: your_api_key_here

2. Authorization Header ile

Authorization: Bearer your_api_key_here

3. Query Parametresi ile

GET http://webservis2.ibu.edu.tr/api/index.php?path=table_name&api_key=your_api_key_here
Güvenlik Uyarısı: Production ortamında query parametresi yerine header kullanmanız önerilir.

Endpoint'ler

Aşağıdaki tablolara erişim sağlanabilir:

HTTP Metodları

Metod Açıklama Endpoint Örneği
GET Veri okuma (listeleme veya tek kayıt) GET /api/index.php?path=table_name

GET İsteği - Veri Okuma

Tüm Kayıtları Listeleme

GET /api/index.php?path={table_name}

Query Parametreleri:

Parametre Açıklama Örnek
page Sayfa numarası (varsayılan: 1) ?page=2
limit Sayfa başına kayıt sayısı (varsayılan: 10, maksimum: 100) ?limit=50
column_name Filtreleme için sütun adı ve değeri ?name=Ahmet

Örnek İstek:

GET http://webservis2.ibu.edu.tr/api/index.php?path=yok_akademik_academician&page=1&limit=10
Headers:
  X-API-Key: your_api_key_here

Örnek Yanıt:

{
  "success": true,
  "data": [
    {
      "id": 1,
      "author_id": "12345",
      "name": "Ahmet Yılmaz",
      "title": "Prof. Dr.",
      "email": "ahmet@example.com"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 10,
    "total": 1279,
    "total_pages": 128
  }
}

Tek Bir Kayıt Getirme

GET /api/index.php?path={table_name}/{id}

Örnek İstek:

GET http://webservis2.ibu.edu.tr/api/index.php?path=yok_akademik_academician/1
Headers:
  X-API-Key: your_api_key_here

Örnek Yanıt:

{
  "success": true,
  "data": {
    "id": 1,
    "author_id": "12345",
    "name": "Ahmet Yılmaz",
    "title": "Prof. Dr.",
    "email": "ahmet@example.com",
    "organization_line": "Üniversite > Fakülte > Bölüm"
  }
}

Hata Kodları

HTTP Kodu Açıklama Örnek Mesaj
400 Bad Request - Geçersiz istek Geçersiz JSON verisi
401 Unauthorized - API key bulunamadı veya geçersiz API key bulunamadı
403 Forbidden - İzin yok Bu tabloya erişim izniniz yok
404 Not Found - Kayıt veya endpoint bulunamadı Tablo bulunamadı
405 Method Not Allowed - Desteklenmeyen HTTP metodu Desteklenmeyen HTTP metodu
500 Internal Server Error - Sunucu hatası Sunucu hatası

İzin Sistemi

Her API key için ayrı ayrı izinler tanımlanabilir:

Örnek Senaryo: Bir API key sadece workers tablosundaki name ve email sütunlarına GET metodu ile erişebilir.

Örnek Kodlar

PHP Örneği

<?php
$apiKey = 'your_api_key_here';
$url = 'http://webservis2.ibu.edu.tr/api/index.php?path=yok_akademik_academician&page=1&limit=10';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'X-API-Key: ' . $apiKey,
    'Content-Type: application/json'
]);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curlError = curl_error($ch);
curl_close($ch);

if ($curlError) {
    echo "cURL Hatası: " . $curlError;
} elseif ($httpCode === 200) {
    $data = json_decode($response, true);
    if ($data) {
        print_r($data);
    } else {
        echo "JSON parse hatası: " . json_last_error_msg();
    }
} else {
    echo "HTTP Hatası: " . $httpCode . "\n";
    echo "Yanıt: " . $response;
}
?>

JavaScript (Fetch API) Örneği

const apiKey = 'your_api_key_here';
const url = 'http://webservis2.ibu.edu.tr/api/index.php?path=yok_akademik_academician&page=1&limit=10';

fetch(url, {
    method: 'GET',
    headers: {
        'X-API-Key': apiKey,
        'Content-Type': 'application/json'
    }
})
.then(response => response.json())
.then(data => {
    console.log(data);
})
.catch(error => {
    console.error('Hata:', error);
});

cURL Örneği

curl -X GET "http://webservis2.ibu.edu.tr/api/index.php?path=yok_akademik_academician&page=1&limit=10" \
  -H "X-API-Key: your_api_key_here" \
  -H "Content-Type: application/json"

Python Örneği

import requests

api_key = 'your_api_key_here'
url = 'http://webservis2.ibu.edu.tr/api/index.php?path=yok_akademik_academician&page=1&limit=10'

headers = {
    'X-API-Key': api_key,
    'Content-Type': 'application/json'
}

params = {
    'page': 1,
    'limit': 10
}

response = requests.get(url, headers=headers, params=params)

if response.status_code == 200:
    data = response.json()
    print(data)
else:
    print(f"Hata: {response.status_code}")

Önemli Notlar

  • API key'inizi güvenli bir yerde saklayın ve asla paylaşmayın
  • Production ortamında HTTPS kullanın
  • Rate limiting (istek sınırlaması) eklemeyi düşünün
  • Düzenli olarak kullanım loglarını kontrol edin
  • Kullanılmayan API key'leri pasif yapın