API Dokümantasyonu
Base URL: https://harem.fiyatapi.tr
FiyatAPI, Harem Altın'ın anlık fiyat verilerini REST API aracılığıyla sunar. Gram altın, çeyrek altın, döviz, maden ve parite verilerine her 10 saniyede güncellenen verilerle ulaşabilirsiniz.
x-api-key header'ı ile kimlik doğrulaması gereklidir. API key almak için fiyatapi.tr adresini ziyaret edin.Kimlik Doğrulama
Tüm korumalı endpoint'ler x-api-key header'ı gerektirir. Key'i URL parametresi olarak asla göndermeyin — sunucu loglarına düşer.
x-api-key: fapi_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
?api_key=... şeklinde URL'ye eklemeyin. Yalnızca x-api-key header'ını kullanın.Rate Limit
Her API key için dakikada 60 istek ve saniyede maksimum 1 istek limiti uygulanır. Limiti aşarsanız 429 hatası alırsınız.
| Header | Açıklama |
|---|---|
| RateLimit-Limit | Pencere başına maksimum istek sayısı (60) |
| RateLimit-Remaining | Kalan istek hakkı |
| RateLimit-Reset | Limitin sıfırlanacağı süre (saniye) |
Yanıt Formatı
Tüm yanıtlar JSON formatındadır. Başarılı yanıtlarda success: true, hatalı yanıtlarda success: false ve error alanı bulunur.
Fiyat Objesi
| Alan | Tip | Açıklama |
|---|---|---|
| symbol | string | Sembol kodu (örn. ALTIN, USDTRY) |
| category | string | Kategori — SARRAFIYE, MADEN, DOVIZ, PARITE |
| bid | number | Alış fiyatı |
| ask | number | Satış fiyatı |
| timestamp | string | Verinin kaynaktaki zaman damgası (ISO 8601) |
{
"symbol": "ALTIN",
"category": "SARRAFIYE",
"bid": 7387.30,
"ask": 7431.12,
"timestamp": "2026-02-26T10:00:00.000Z"
}
Sağlık Kontrolü
Servisin çalışıp çalışmadığını ve verinin hazır olup olmadığını döner. Auth gerektirmez.
curl https://harem.fiyatapi.tr/health
Yanıt
{
"status": "ok",
"ready": true,
"uptime": 3600,
"lastUpdate": "2026-02-26T10:00:00.000Z"
}
| Alan | Tip | Açıklama |
|---|---|---|
| status | string | Her zaman "ok" |
| ready | boolean | false ise ilk veri henüz yüklenmemiş |
| uptime | number | Sunucunun çalışma süresi (saniye) |
| lastUpdate | string | Son veri çekiminin zamanı |
Tüm Fiyatlar
Sistemdeki tüm sembollerin anlık fiyatlarını döner (66 sembol).
curl https://harem.fiyatapi.tr/api/prices \
-H "x-api-key: fapi_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Yanıt
{
"success": true,
"count": 66,
"lastUpdate": "2026-02-26T10:00:00.000Z",
"data": [
{
"symbol": "ALTIN",
"category": "SARRAFIYE",
"bid": 7387.30,
"ask": 7431.12,
"timestamp":"2026-02-26T10:00:00.000Z"
},
// ... 65 sembol daha
]
}
Tekil Sembol
Belirli bir sembolün anlık fiyatını döner. Sembol büyük/küçük harf duyarsızdır.
| Parametre | Yer | Açıklama |
|---|---|---|
| symbol zorunlu | Path | Sembol kodu (örn. ALTIN, USDTRY, XAUUSD) |
curl https://harem.fiyatapi.tr/api/prices/ALTIN \
-H "x-api-key: fapi_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Yanıt
{
"success": true,
"lastUpdate": "2026-02-26T10:00:00.000Z",
"data": {
"symbol": "ALTIN",
"category": "SARRAFIYE",
"bid": 7387.30,
"ask": 7431.12,
"timestamp": "2026-02-26T10:00:00.000Z"
}
}
{
"success": false,
"error": "'XYZ' sembolü bulunamadı"
}
Kategoriye Göre Fiyatlar
Belirli bir kategorideki tüm sembolleri döner. Mevcut kategoriler: SARRAFIYE, MADEN, DOVIZ, PARITE.
| Parametre | Yer | Açıklama |
|---|---|---|
| category zorunlu | Path | Kategori adı (büyük/küçük harf duyarsız) |
curl https://harem.fiyatapi.tr/api/prices/category/DOVIZ \
-H "x-api-key: fapi_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Yanıt
{
"success": true,
"category": "DOVIZ",
"count": 8,
"lastUpdate": "2026-02-26T10:00:00.000Z",
"data": [ /* USDTRY, EURTRY, GBPTRY ... */ ]
}
{
"success": false,
"error": "'xyz' kategorisinde veri bulunamadı",
"availableCategories":["SARRAFIYE","MADEN","DOVIZ","PARITE"]
}
Sembol Arama
Sembol kodu veya açıklamasında arama yapar. En az 2 karakter girilmelidir.
| Parametre | Yer | Açıklama |
|---|---|---|
| query zorunlu | Path | Arama terimi, min. 2 karakter |
curl https://harem.fiyatapi.tr/api/prices/search/usd \
-H "x-api-key: fapi_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Yanıt
{
"success": true,
"query": "usd",
"count": 3,
"lastUpdate": "2026-02-26T10:00:00.000Z",
"data": [ /* USDTRY, XAUUSD, GUMUSD ... */ ]
}
İstatistikler
Toplam sembol sayısı, kategori dağılımı ve sistem bilgilerini döner.
curl https://harem.fiyatapi.tr/api/stats \
-H "x-api-key: fapi_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Yanıt
{
"success": true,
"totalSymbols": 66,
"lastUpdate": "2026-02-26T10:00:00.000Z",
"updateCount": 8640,
"isReady": true,
"uptime": 86400,
"categories": {
"SARRAFIYE": 16,
"MADEN": 11,
"DOVIZ": 8,
"PARITE": 2
}
}
Sembol Listesi
🪙 Sarrafiye (SARRAFIYE)
⚖️ Maden (MADEN)
💱 Döviz (DOVIZ)
🔄 Parite (PARITE)
Kategoriler
Kategoriye göre filtreleme için aşağıdaki değerleri kullanın (büyük/küçük harf duyarsız):
Hata Kodları
| HTTP | Sebep | Çözüm |
|---|---|---|
| 200 | Başarılı | — |
| 400 | Geçersiz istek (örn. arama terimi çok kısa) | Parametreleri kontrol edin |
| 401 | x-api-key header'ı eksik |
Header'ı ekleyin |
| 403 | Geçersiz veya deaktif API key | Doğru key'i kullandığınızdan emin olun |
| 404 | Sembol veya kategori bulunamadı | Sembol listesini kontrol edin |
| 429 | Rate limit aşıldı | 1 dakika bekleyin (120 istek/dk) |
| 503 | Servis başlıyor, veri henüz hazır değil | 10–15 saniye bekleyip tekrar deneyin |
JavaScript
const API_KEY = 'fapi_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; const BASE = 'https://harem.fiyatapi.tr'; async function getPrice(symbol) { const res = await fetch(`${BASE}/api/prices/${symbol}`, { headers: { 'x-api-key': API_KEY } }); if (!res.ok) throw new Error(`HTTP ${res.status}`); const json = await res.json(); return json.data; } async function getAllPrices() { const res = await fetch(`${BASE}/api/prices`, { headers: { 'x-api-key': API_KEY } }); const json = await res.json(); return json.data; } // Kullanım const altin = await getPrice('ALTIN'); console.log(`Gram Altın alış: ${altin.bid} ₺, satış: ${altin.ask} ₺`); const usd = await getPrice('USDTRY'); console.log(`USD/TRY: ${usd.bid} / ${usd.ask}`);
Python
import requests API_KEY = 'fapi_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' BASE_URL = 'https://harem.fiyatapi.tr' HEADERS = {'x-api-key': API_KEY} def get_price(symbol: str) -> dict: res = requests.get(f'{BASE_URL}/api/prices/{symbol}', headers=HEADERS) res.raise_for_status() return res.json()['data'] def get_by_category(category: str) -> list: res = requests.get( f'{BASE_URL}/api/prices/category/{category}', headers=HEADERS ) res.raise_for_status() return res.json()['data'] # Kullanım altin = get_price('ALTIN') print(f"Gram Altın — Alış: {altin['bid']} ₺, Satış: {altin['ask']} ₺") dovizler = get_by_category('DOVIZ') for d in dovizler: print(f"{d['symbol']}: {d['bid']}")
PHP
<?php define('API_KEY', 'fapi_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); define('BASE_URL', 'https://harem.fiyatapi.tr'); function apiRequest(string $path): array { $ch = curl_init(BASE_URL . $path); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ['x-api-key: ' . API_KEY], ]); $body = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($status !== 200) { throw new \Exception("API Hatası: HTTP $status"); } return json_decode($body, true); } // Tek sembol $altin = apiRequest('/api/prices/ALTIN')['data']; echo "Gram Altın — Alış: {$altin['bid']} ₺, Satış: {$altin['ask']} ₺\n"; // Kategoriye göre $dovizler = apiRequest('/api/prices/category/DOVIZ')['data']; foreach ($dovizler as $d) { echo "{$d['symbol']}: {$d['bid']}\n"; }