Skip to Content

Kullanım

API kullanım istatistiklerinizi sorgulayın: aylık istek sayısı, kredi tüketimi, en çok kullanılan endpoint’ler ve son isteklerin özeti.


Kullanım İstatistikleri

GET/v1/usage

Mevcut API anahtarının kullanım özetini döner.

Kod Örnekleri

kullanim-ozet.js
const response = await fetch('https://api.sosyalkopru.com/v1/usage', { headers: { 'Authorization': `Bearer ${process.env.SOSYALKOPRU_API_KEY}` }, }) const { data } = await response.json() console.log('=== Hesap ===') console.log(`Plan : ${data.apiKey.planTier}`) console.log(`Kredi : ${data.apiKey.creditBalance.toLocaleString('tr-TR')}`) console.log(`Toplam : ${data.apiKey.totalRequests.toLocaleString('tr-TR')} istek`) console.log('\n=== Bu Ay ===') console.log(`İstekler : ${data.currentMonth.requests.toLocaleString('tr-TR')}`) console.log(`Kredi har.: ${data.currentMonth.creditsUsed.toLocaleString('tr-TR')}`) // Kredi uyarısı if (data.apiKey.creditBalance < 100) { console.warn('\n⚠️ Kredi bakiyeniz düşük! Lütfen yükleyin.') } console.log('\n=== En Çok Kullanılan Endpoint\'ler ===') data.topEndpoints.forEach(e => { console.log(` ${e.requests.toString().padStart(6)} istek ${e.endpoint}`) }) console.log('\n=== Son 10 İstek ===') data.recentRequests.forEach(r => { const ok = r.statusCode < 400 ? '✓' : '✗' console.log(`${ok} ${r.method} ${r.endpoint} [${r.statusCode}] ${r.durationMs}ms`) })

Başarılı Yanıt

{ "success": true, "data": { "apiKey": { "id": "key_01HZGK9P3QABC", "name": "Üretim Anahtarı", "planTier": "growth", "creditBalance": 842, "totalRequests": 12480, "expiresAt": null, "lastUsedAt": "2025-06-12T09:30:00.000Z" }, "currentMonth": { "requests": 1240, "creditsUsed": 158, "periodStart": "2025-06-01T00:00:00.000Z", "periodEnd": "2025-06-30T00:00:00.000Z" }, "topEndpoints": [ { "endpoint": "/v1/posts", "requests": 420 }, { "endpoint": "/v1/analytics/overview", "requests": 218 }, { "endpoint": "/v1/accounts", "requests": 186 }, { "endpoint": "/v1/media/upload", "requests": 124 }, { "endpoint": "/v1/webhooks", "requests": 97 } ], "recentRequests": [ { "endpoint": "/v1/posts", "method": "POST", "statusCode": 201, "creditsUsed": 2, "durationMs": 142, "timestamp": "2025-06-12T09:30:00.000Z" }, { "endpoint": "/v1/analytics/overview", "method": "GET", "statusCode": 200, "creditsUsed": 1, "durationMs": 87, "timestamp": "2025-06-12T09:28:00.000Z" } ] }, "meta": { "requestId": "req_01XYZ", "timestamp": "...", "version": "1" } }

Yanıt Alanları

AlanAçıklama
apiKey.planTierstarter growth agency_pro
apiKey.creditBalanceKalan kredi miktarı
apiKey.totalRequestsAPI anahtarının ömür boyu toplam istek sayısı
currentMonth.requestsBu ayki toplam istek sayısı (tüm durum kodları)
currentMonth.creditsUsedBu ayki başarılı isteklerde harcanan kredi
topEndpointsBu ay en çok kullanılan 10 endpoint (istek sayısına göre sıralı)
recentRequestsSon 10 istek (en yeniden eskiye)

Kredi Maliyetleri

İşlemKredi
GET /posts, GET /accounts vb. okuma1
POST /posts (gönderi oluşturma)2
POST /media/upload2
GET /analytics/*1
POST /posts/bulk1 + gönderi başına 1
GET /usage, GET /me0
Last updated on