Documentation Index
Fetch the complete documentation index at: https://docs.octav.fi/llms.txt
Use this file to discover all available pages before exploring further.
Check your remaining API credit balance at any time without consuming credits.
Endpoint
GET https://api.octav.fi/v1/credits
No parameters required.
Example
curl "https://api.octav.fi/v1/credits" \
-H "Authorization: Bearer YOUR_API_KEY"
Response
Returns a simple number representing your remaining credits.
Use Cases
Monitor Balance
Alert on Low Balance
Track Usage
Budget Management
Check credits before expensive operations:async function checkCreditsBeforeSync(address) {
// Check available credits
const response = await fetch('https://api.octav.fi/v1/credits', {
headers: { 'Authorization': `Bearer ${apiKey}` }
});
const credits = await response.json();
console.log(`Available credits: ${credits}`);
// Estimate sync cost (rough estimate)
const statusResponse = await fetch(
`https://api.octav.fi/v1/status?addresses=${address}`,
{ headers: { 'Authorization': `Bearer ${apiKey}` } }
);
const [status] = await statusResponse.json();
if (credits < 50) {
console.warn('Low credits! Consider purchasing more.');
return false;
}
// Proceed with sync
await fetch('https://api.octav.fi/v1/sync-transactions', {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ addresses: [address] })
});
return true;
}
Set up alerts for low credit balance:async function monitorCredits(threshold = 1000) {
const response = await fetch('https://api.octav.fi/v1/credits', {
headers: { 'Authorization': `Bearer ${apiKey}` }
});
const credits = await response.json();
if (credits < threshold) {
console.warn(`⚠️ Low credit balance: ${credits}`);
console.warn(`Purchase more at https://data.octav.fi/`);
// Send notification (email, Slack, etc.)
await sendAlert({
message: `API credits low: ${credits} remaining`,
severity: 'warning'
});
} else {
console.log(`✓ Credit balance healthy: ${credits}`);
}
return credits;
}
// Run periodically
setInterval(() => monitorCredits(1000), 3600000); // Every hour
Track credit consumption over time:class CreditTracker {
constructor(apiKey) {
this.apiKey = apiKey;
this.snapshots = [];
}
async snapshot() {
const response = await fetch('https://api.octav.fi/v1/credits', {
headers: { 'Authorization': `Bearer ${this.apiKey}` }
});
const credits = await response.json();
const snapshot = {
timestamp: new Date().toISOString(),
credits
};
this.snapshots.push(snapshot);
return snapshot;
}
getUsageSince(timestamp) {
const snapshots = this.snapshots.filter(
s => new Date(s.timestamp) >= new Date(timestamp)
);
if (snapshots.length < 2) return 0;
return snapshots[0].credits - snapshots[snapshots.length - 1].credits;
}
async getCurrentUsageRate() {
// Take snapshots 1 minute apart
const snapshot1 = await this.snapshot();
await new Promise(resolve => setTimeout(resolve, 60000));
const snapshot2 = await this.snapshot();
const creditsUsed = snapshot1.credits - snapshot2.credits;
const creditsPerHour = creditsUsed * 60;
console.log(`Usage rate: ${creditsUsed} credits/min`);
console.log(`Projected: ${creditsPerHour} credits/hour`);
console.log(`Days remaining: ${(snapshot2.credits / (creditsPerHour * 24)).toFixed(1)}`);
return {
creditsPerMinute: creditsUsed,
creditsPerHour,
daysRemaining: snapshot2.credits / (creditsPerHour * 24)
};
}
}
const tracker = new CreditTracker(apiKey);
const usage = await tracker.getCurrentUsageRate();
Implement credit budgets:class CreditBudget {
constructor(apiKey, dailyBudget) {
this.apiKey = apiKey;
this.dailyBudget = dailyBudget;
this.startCredits = null;
this.startDate = null;
}
async initialize() {
const response = await fetch('https://api.octav.fi/v1/credits', {
headers: { 'Authorization': `Bearer ${this.apiKey}` }
});
this.startCredits = await response.json();
this.startDate = new Date();
console.log(`Budget initialized: ${this.dailyBudget} credits/day`);
console.log(`Starting balance: ${this.startCredits}`);
}
async checkBudget() {
const response = await fetch('https://api.octav.fi/v1/credits', {
headers: { 'Authorization': `Bearer ${this.apiKey}` }
});
const currentCredits = await response.json();
const usedToday = this.startCredits - currentCredits;
const remainingBudget = this.dailyBudget - usedToday;
console.log(`Used today: ${usedToday}/${this.dailyBudget}`);
console.log(`Remaining budget: ${remainingBudget}`);
if (remainingBudget <= 0) {
throw new Error('Daily credit budget exceeded!');
}
return {
used: usedToday,
remaining: remainingBudget,
percentage: (usedToday / this.dailyBudget * 100).toFixed(2)
};
}
}
const budget = new CreditBudget(apiKey, 1000); // 1000 credits/day
await budget.initialize();
const status = await budget.checkBudget();
Best Practices
Since this endpoint is free, check it liberally:
- Before expensive operations
- In application health checks
- When displaying usage stats to users
Implement automated alerts:
- Alert at 20% remaining
- Warning at 10% remaining
- Critical at 5% remaining
Monitor consumption patterns:
- Track daily usage
- Forecast when credits will run out
- Purchase credits before running low
Pricing
View credit packages and pricing
Status
Check sync status (also free)
Developer Portal
Purchase more credits