Endpoint
GET https://altinapi.com/api/prices/TEK_YENI
cURL
bash
curl -H "x-api-key: hapi_xxxx" \
https://altinapi.com/api/prices/TEK_YENI
JSON Yanıt
JSON
{
"symbol": "TEK_YENI",
"category": "SARRAFIYE",
"bid": 22720.00, // alış fiyatı (TL/adet)
"ask": 22880.00, // satış fiyatı (TL/adet)
"timestamp": 1741784400000 // Unix ms
}
Python
Python
import requests API_KEY = "hapi_xxxx" url = "https://altinapi.com/api/prices/TEK_YENI" resp = requests.get(url, headers={"x-api-key": API_KEY}, timeout=5) data = resp.json() print(f"Tam Altın alış: {data['bid']} TL/adet") print(f"Tam Altın satış: {data['ask']} TL/adet")
JavaScript
JavaScript (fetch)
const resp = await fetch("https://altinapi.com/api/prices/TEK_YENI", { headers: { "x-api-key": "hapi_xxxx" }, }); const data = await resp.json(); console.log(`Tam Altın alış: ${data.bid} TL/adet`); console.log(`Tam Altın satış: ${data.ask} TL/adet`);
WebSocket Aboneliği
Fiyat her değiştiğinde anlık almak için WebSocket kullanın:
JavaScript (socket.io-client)
import { io } from "socket.io-client"; const socket = io("https://altinapi.com", { auth: { apiKey: "hapi_xxxx" }, }); socket.on("connect", () => { socket.emit("subscribe", ["TEK_YENI"]); }); socket.on("prices:update", ({ data }) => { const tek = data.find(p => p.symbol === "TEK_YENI"); if (tek) console.log(tek.bid, tek.ask); });
Tüm Fiyatlarla Birlikte
Tek istekte tüm kategorileri çekmek için /api/prices kullanın:
GET https://altinapi.com/api/prices
Yanıtta category: "SARRAFIYE" olanları filtreleyin — TEK_YENI bu grupta yer alır.