API Token Bilgileri

Kullanıcı Adı ve Şifre ile Bağlanma

API'ye kullanıcı adı ve şifre ile bağlanmak için Basic Authentication kullanabilirsiniz. Bu yöntem otomatik olarak JWT token'a dönüştürülür ve işlem devam eder.

Not: API erişim yetkisi olan kullanıcılar hem kullanıcı adı-şifre ile hem de doğrudan JWT token ile bağlanabilir.
Gereksinimler:
  • API erişim yetkisi olan bir kullanıcı hesabı (HasApiAccess = true)
  • Geçerli kullanıcı adı ve şifre
  • Basic Authentication header formatı: Basic BASE64(username:password)
Nasıl Çalışır:
  1. İstek Authorization: Basic BASE64(username:password) header'ı ile gelir
  2. Sistem kullanıcı adı ve şifreyi IdentityServer'da doğrular
  3. Kullanıcının API erişimi varsa (HasApiAccess = true), otomatik olarak JWT token oluşturulur
  4. Basic Auth header'ı Authorization: Bearer JWT_TOKEN ile değiştirilir
  5. İstek normal JWT authentication flow ile devam eder
Örnek Kullanım:
curl:
curl -X POST https://ai.sobe.net.tr/api/ApiChat/send-message \
  -H "Authorization: Basic BASE64(username:password)" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Merhaba"
  }'
JavaScript (fetch):
const username = 'kullanici_adi';
const password = 'sifre';
const credentials = btoa(`${username}:${password}`);

fetch('https://ai.sobe.net.tr/api/ApiChat/send-message', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${credentials}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    message: 'Merhaba'
  })
})
.then(response => response.json())
.then(data => console.log(data));
Python (requests):
import requests
import base64

username = 'kullanici_adi'
password = 'sifre'
credentials = base64.b64encode(f"{username}:{password}".encode()).decode()

headers = {
    'Authorization': f'Basic {credentials}',
    'Content-Type': 'application/json'
}

response = requests.post(
    'https://ai.sobe.net.tr/api/ApiChat/send-message',
    headers=headers,
    json={'message': 'Merhaba'}
)

print(response.json())
İpucu: Base64 encoding için online araçlar kullanabilir veya yukarıdaki kod örneklerindeki yöntemleri kullanabilirsiniz.
Token ile Bağlanma

API'ye doğrudan JWT Bearer Token ile bağlanmak için IdentityServer üzerinden token almanız gerekir.

İki Yöntem: Token'ı önceden alıp kullanabilirsiniz, veya Basic Auth kullanarak otomatik token alabilirsiniz.
Token Alma Yöntemleri:
  1. OpenID Connect: IdentityServer'a giriş yapın: https://hesap.sobe.net.tr ve OpenID Connect flow ile token alın
  2. Basic Auth: Yukarıdaki "Kullanıcı Adı ve Şifre ile Bağlanma" yöntemini kullanın - otomatik token oluşturulur
  3. Manuel: IdentityServer'ın token endpoint'ini kullanarak manuel token alın
Gereksinimler:
  • API erişim yetkisi olan bir kullanıcı (HasApiAccess = true)
  • Geçerli JWT Bearer Token
  • Token header formatı: Authorization: Bearer YOUR_JWT_TOKEN
Örnek Kullanım:
curl:
curl -X POST https://ai.sobe.net.tr/api/ApiChat/send-message \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Merhaba"
  }'
JavaScript (fetch):
const token = 'YOUR_JWT_TOKEN';

fetch('https://ai.sobe.net.tr/api/ApiChat/send-message', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    message: 'Merhaba'
  })
})
.then(response => response.json())
.then(data => console.log(data));
Python (requests):
import requests

token = 'YOUR_JWT_TOKEN'

headers = {
    'Authorization': f'Bearer {token}',
    'Content-Type': 'application/json'
}

response = requests.post(
    'https://ai.sobe.net.tr/api/ApiChat/send-message',
    headers=headers,
    json={'message': 'Merhaba'}
)

print(response.json())
Önemli: Token'ınızı güvenli bir şekilde saklayın ve asla paylaşmayın. Token süresi dolduğunda yeni bir token almanız gerekir.
Personal Access Token (Önerilen)

Her kullanıcı kendi uzun süreli token'ını oluşturabilir. Bu yöntem en güvenli ve en kolay yöntemdir.

Nasıl Kullanılır:
  1. My Tokens sayfasına gidin
  2. Yeni bir token oluşturun ve token değerini kopyalayın
  3. API isteklerinizde X-API-Token header'ı ile kullanın
curl:
curl -X POST https://ai.sobe.net.tr/api/ApiChat/send-message \
  -H "X-API-Token: YOUR_PERSONAL_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"message": "Merhaba"}'
JavaScript (fetch):
const token = 'YOUR_PERSONAL_ACCESS_TOKEN';

fetch('https://ai.sobe.net.tr/api/ApiChat/send-message', {
  method: 'POST',
  headers: {
    'X-API-Token': token,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    message: 'Merhaba'
  })
})
.then(response => response.json())
.then(data => console.log(data));
Python (requests):
import requests

token = 'YOUR_PERSONAL_ACCESS_TOKEN'

headers = {
    'X-API-Token': token,
    'Content-Type': 'application/json'
}

response = requests.post(
    'https://ai.sobe.net.tr/api/ApiChat/send-message',
    headers=headers,
    json={'message': 'Merhaba'}
)

print(response.json())
Ana API Endpoint'leri
Endpoint Method Açıklama
/api/ApiChat/send-message POST Mesaj gönder ve AI yanıtı al
/api/ApiChat/conversations GET Tüm konuşmaları listele
/api/ApiChat/conversations/{id} GET Belirli bir konuşmayı getir
/swagger GET Swagger API dokümantasyonu
Detaylı Dokümantasyon: Swagger UI'ı ziyaret edin tüm endpoint'ler ve parametreler için detaylı bilgi almak için.
Ek Bilgiler
Kimlik Doğrulama:
  • Basic Authentication (kullanıcı adı:şifre base64 encoded)
  • Bearer Token (JWT)
Token Süresi:
  • Access Token: 60 dakika
  • Refresh Token: 7 gün
Güvenlik:
  • Tüm istekler HTTPS üzerinden yapılmalıdır
  • Token'ları güvenli bir şekilde saklayın
  • Token'ları asla client-side kodda expose etmeyin
Base URL:
  • https://ai.sobe.net.tr
  • IdentityServer: https://hesap.sobe.net.tr
An unhandled error has occurred. Reload 🗙