FortiBlox LogoFortiBlox Docs
ExplorerTools

🔧 API Access

Access FortiBlox Explorer data programmatically with our comprehensive REST API, WebSocket feeds, and developer tools.

API Access

Developer API Integration: Access FortiBlox Explorer data programmatically with our comprehensive REST API, WebSocket feeds, and developer tools.

The FortiBlox Explorer API provides developers with programmatic access to all blockchain data, analytics, and real-time feeds. Build applications, create custom dashboards, and integrate blockchain data into your projects.

API Overview

Getting Started

API Access Tiers

Free Tier

Free API Access:
- 1,000 requests/hour
- Basic endpoints
- No API key required
- Rate limited
- Best effort support

Developer Tier

Developer API Access:
- 10,000 requests/hour
- All endpoints
- API key required
- Priority support
- $29/month

Professional Tier

Professional API Access:
- 100,000 requests/hour
- All endpoints + premium data
- Dedicated support
- Custom rate limits
- $149/month

Quick Start

1. Get API Key

# Sign up for API access
curl -X POST https://api.fortiblox.com/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email": "[email protected]", "tier": "developer"}'

2. First API Call

const response = await fetch('https://api.fortiblox.com/v1/account/9YQqcJdXukHNa7J8PbUbGJt3sHgwqPhkMPPv5B2zDqwj', {
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
});

const accountData = await response.json();
console.log('SOL Balance:', accountData.balance);

Authentication

API Key Management

Obtaining API Keys

  1. Register Account: Sign up at api.fortiblox.com
  2. Choose Tier: Select appropriate access tier
  3. Generate Key: Create API key in dashboard
  4. Secure Storage: Store key securely in your application

Authentication Methods

// Bearer Token (Recommended)
headers: {
  'Authorization': 'Bearer YOUR_API_KEY'
}

// API Key Header
headers: {
  'X-API-Key': 'YOUR_API_KEY'
}

// Query Parameter (Not recommended for production)
'?api_key=YOUR_API_KEY'

Security Best Practices

Key Management

  • Environment Variables: Store keys in environment variables
  • Rotation: Rotate keys regularly (monthly recommended)
  • Scope Limitation: Use minimum required permissions
  • Monitoring: Monitor API key usage for anomalies

Request Security

// Secure API request example
const apiCall = async (endpoint, options = {}) => {
  const response = await fetch(`https://api.fortiblox.com/v1/${endpoint}`, {
    headers: {
      'Authorization': `Bearer ${process.env.FORTIBLOX_API_KEY}`,
      'Content-Type': 'application/json',
      'User-Agent': 'YourApp/1.0',
      ...options.headers
    },
    ...options
  });
  
  if (!response.ok) {
    throw new Error(`API Error: ${response.status} ${response.statusText}`);
  }
  
  return response.json();
};

REST API

Core Endpoints

Account Endpoints

// Get account information
GET /v1/account/{address}

// Get account balance
GET /v1/account/{address}/balance

// Get account transactions  
GET /v1/account/{address}/transactions

// Get token holdings
GET /v1/account/{address}/tokens

// Example
const account = await apiCall('account/9YQqcJdXukHNa7J8PbUbGJt3sHgwqPhkMPPv5B2zDqwj');

Transaction Endpoints

// Get transaction details
GET /v1/transaction/{signature}

// Get recent transactions
GET /v1/transactions/recent

// Search transactions
GET /v1/transactions/search?q={query}

// Example
const transaction = await apiCall('transaction/5j7s8k9l2m3n4p5q6r7s8t9u1v2w3x4y5z6a7b8c9d1e2f3g4h5i6j7k8l9m');

Block Endpoints

// Get block information
GET /v1/block/{slot}

// Get recent blocks
GET /v1/blocks/recent

// Get block transactions
GET /v1/block/{slot}/transactions

// Example
const block = await apiCall('block/12345');

Market Data Endpoints

Price Data

// Get token prices
GET /v1/market/prices

// Get specific token price
GET /v1/market/price/{mint}

// Get price history
GET /v1/market/history/{mint}?days=30&interval=1h

// Example
const prices = await apiCall('market/prices');
const solPrice = prices.SOL.usd;

DeFi Data

// Get protocol TVL data
GET /v1/defi/protocols

// Get yield opportunities
GET /v1/defi/yields

// Get liquidity pools
GET /v1/defi/pools

// Example
const protocols = await apiCall('defi/protocols');
const topProtocol = protocols[0];

WebSocket API

Real-time Data Streams

Connection Setup

const ws = new WebSocket('wss://api.fortiblox.com/v1/ws');

ws.onopen = () => {
  // Authenticate
  ws.send(JSON.stringify({
    type: 'auth',
    api_key: 'YOUR_API_KEY'
  }));
};

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  console.log('Received:', data);
};

Subscription Types

// Subscribe to account updates
ws.send(JSON.stringify({
  type: 'subscribe',
  channel: 'account',
  address: '9YQqcJdXukHNa7J8PbUbGJt3sHgwqPhkMPPv5B2zDqwj'
}));

// Subscribe to new transactions
ws.send(JSON.stringify({
  type: 'subscribe',
  channel: 'transactions',
  filter: 'all' // or 'successful', 'failed'
}));

// Subscribe to price updates
ws.send(JSON.stringify({
  type: 'subscribe',
  channel: 'prices',
  tokens: ['SOL', 'USDC', 'RAY']
}));

SDKs and Libraries

Official SDKs

JavaScript/TypeScript

npm install @fortiblox/explorer-sdk
import { FortiBloxExplorer } from '@fortiblox/explorer-sdk';

const explorer = new FortiBloxExplorer({
  apiKey: 'YOUR_API_KEY',
  network: 'mainnet'
});

// Get account data
const account = await explorer.account.get('9YQqcJdXukHNa7J8PbUbGJt3sHgwqPhkMPPv5B2zDqwj');

// Subscribe to updates
explorer.subscribe.account('address', (data) => {
  console.log('Balance updated:', data.balance);
});

Python

pip install fortiblox-explorer
from fortiblox_explorer import FortiBloxExplorer

explorer = FortiBloxExplorer(api_key='YOUR_API_KEY')

# Get account data
account = explorer.account.get('9YQqcJdXukHNa7J8PbUbGJt3sHgwqPhkMPPv5B2zDqwj')
print(f"Balance: {account.balance} SOL")

# Get market data
prices = explorer.market.get_prices()
print(f"SOL Price: ${prices['SOL']['usd']}")

Go

go get github.com/fortiblox/explorer-go
package main

import (
    "fmt"
    "github.com/fortiblox/explorer-go"
)

func main() {
    client := explorer.New("YOUR_API_KEY")
    
    account, err := client.Account.Get("9YQqcJdXukHNa7J8PbUbGJt3sHgwqPhkMPPv5B2zDqwj")
    if err != nil {
        panic(err)
    }
    
    fmt.Printf("Balance: %f SOL\n", account.Balance)
}

Error Handling

HTTP Status Codes

Success Codes

  • 200 OK: Successful request
  • 201 Created: Resource created successfully
  • 202 Accepted: Request accepted for processing

Error Codes

4xx Client Errors:
- 400 Bad Request: Invalid request parameters
- 401 Unauthorized: Invalid or missing API key
- 403 Forbidden: Insufficient permissions
- 404 Not Found: Resource not found
- 429 Too Many Requests: Rate limit exceeded

5xx Server Errors:
- 500 Internal Server Error: Server error
- 502 Bad Gateway: Upstream service error
- 503 Service Unavailable: Service temporarily unavailable

Error Response Format

{
  "error": {
    "code": "INVALID_ADDRESS",
    "message": "The provided address format is invalid",
    "details": {
      "address": "invalid_address",
      "expected_format": "base58 string, 44 characters"
    }
  }
}

Rate Limiting

Rate Limit Headers

Response Headers:
- X-RateLimit-Limit: Maximum requests per window
- X-RateLimit-Remaining: Requests remaining in window
- X-RateLimit-Reset: Unix timestamp when limit resets
- Retry-After: Seconds to wait when rate limited

Rate Limit Handling

const makeRequest = async (endpoint) => {
  const response = await fetch(`https://api.fortiblox.com/v1/${endpoint}`, {
    headers: { 'Authorization': `Bearer ${API_KEY}` }
  });

  // Check rate limit headers
  const limit = response.headers.get('X-RateLimit-Limit');
  const remaining = response.headers.get('X-RateLimit-Remaining');
  const reset = response.headers.get('X-RateLimit-Reset');

  console.log(`Rate limit: ${remaining}/${limit} remaining`);

  if (response.status === 429) {
    const retryAfter = response.headers.get('Retry-After');
    throw new Error(`Rate limited. Retry after ${retryAfter} seconds`);
  }

  return response.json();
};

Best Practices

Performance Optimization

Caching

const cache = new Map();
const CACHE_TTL = 60000; // 1 minute

const getCachedData = async (key, fetchFn) => {
  const cached = cache.get(key);
  if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
    return cached.data;
  }
  
  const data = await fetchFn();
  cache.set(key, { data, timestamp: Date.now() });
  return data;
};

// Usage
const accountData = await getCachedData(
  `account_${address}`,
  () => apiCall(`account/${address}`)
);

Batch Requests

// Batch multiple account requests
const addresses = ['addr1', 'addr2', 'addr3'];
const accounts = await Promise.all(
  addresses.map(addr => apiCall(`account/${addr}`))
);

// Use bulk endpoints when available
const bulkAccounts = await apiCall('accounts/bulk', {
  method: 'POST',
  body: JSON.stringify({ addresses })
});

Next Steps