SDK Examples
Code snippets for Python, JavaScript, and cURL
Authentication: Replace
YOUR_API_KEY with your actual API key from /subscribe
Quick Start
cURL
curl -H "X-API-Key: YOUR_API_KEY" \
https://api.feedoracle.io/api/v1/feeds/health
Python
import requests
API_KEY = "YOUR_API_KEY"
BASE_URL = "https://api.feedoracle.io"
headers = {"X-API-Key": API_KEY}
# Get RWA Health data
response = requests.get(f"{BASE_URL}/api/v1/feeds/health", headers=headers)
data = response.json()
print(f"Feed: {data['meta']['feed_name']}")
print(f"As of: {data['meta']['as_of']}")
JavaScript (Node.js)
const API_KEY = "YOUR_API_KEY";
const BASE_URL = "https://api.feedoracle.io";
async function getHealth() {
const response = await fetch(`${BASE_URL}/api/v1/feeds/health`, {
headers: { "X-API-Key": API_KEY }
});
const data = await response.json();
console.log(`Feed: ${data.meta.feed_name}`);
console.log(`As of: ${data.meta.as_of}`);
}
getHealth();
Carbon Data
Python - Get All Chains
# Get carbon data for all blockchain networks
response = requests.get(f"{BASE_URL}/api/v1/carbon/chains", headers=headers)
chains = response.json()
for chain in chains.get("data", [])[:5]:
print(f"{chain['symbol']}: {chain.get('carbon_intensity', 'N/A')} gCO2/kWh")
JavaScript - Carbon Summary
const summary = await fetch(`${BASE_URL}/api/v1/carbon/summary`, {
headers: { "X-API-Key": API_KEY }
}).then(r => r.json());
console.log(`Total networks: ${summary.meta.total_networks}`);
World Bank Data
Python - Country GDP
# Get Germany's economic indicators
response = requests.get(f"{BASE_URL}/worldbank/country/DEU", headers=headers)
data = response.json()
gdp = data["indicators"]["GDP_USD"]["value"]
print(f"Germany GDP: ${gdp:,.0f}")
Macro Oracle (FRED)
Python - Economic Health
# Get US economic health score
response = requests.get(f"{BASE_URL}/macro/api/v1/macro/health", headers=headers)
health = response.json()
print(f"Economic Health: {health.get('score', 'N/A')}")
print(f"Updated: {health['meta']['as_of']}")
DAP Attestation
Python - Verify Attestation
# Check DAP attestation status
response = requests.get(f"{BASE_URL}/api/v2/attestation/status", headers=headers)
status = response.json()
print(f"Last anchor: {status.get('last_anchor_time')}")
print(f"Chains: {', '.join(status.get('chains', []))}")
Error Handling
Python - Handle Errors
def api_call(endpoint):
try:
response = requests.get(f"{BASE_URL}{endpoint}", headers=headers)
response.raise_for_status()
return response.json()
except requests.exceptions.HTTPError as e:
error = response.json()
print(f"Error {error['error']['code']}: {error['error']['message']}")
print(f"Request ID: {error['meta']['request_id']}")
return None
data = api_call("/api/v1/feeds/health")
JavaScript - Handle Errors
async function apiCall(endpoint) {
const response = await fetch(`${BASE_URL}${endpoint}`, {
headers: { "X-API-Key": API_KEY }
});
const data = await response.json();
if (!response.ok) {
console.error(`Error ${data.error.code}: ${data.error.message}`);
console.error(`Request ID: ${data.meta.request_id}`);
return null;
}
return data;
}
A2A Pay-per-Call
cURL - Check Pricing
# No auth required for pricing
curl https://api.feedoracle.io/a2a/pricing
Python - Pay-per-Call Flow
# 1. Check pricing (no auth)
pricing = requests.get(f"{BASE_URL}/a2a/pricing").json()
print(f"macro/health costs: ${pricing['feeds']['macro/health']}")
# 2. After USDC payment, call with tx hash
tx_hash = "0x123..." # Your payment tx
response = requests.get(
f"{BASE_URL}/a2a/feed/macro/health?tx={tx_hash}",
headers=headers
)
data = response.json()
Full Python Client
class FeedOracleClient:
def __init__(self, api_key):
self.api_key = api_key
self.base_url = "https://api.feedoracle.io"
self.headers = {"X-API-Key": api_key}
def get(self, endpoint):
r = requests.get(f"{self.base_url}{endpoint}", headers=self.headers)
r.raise_for_status()
return r.json()
def carbon(self): return self.get("/api/v1/carbon/chains")
def macro(self): return self.get("/macro/api/v1/macro/health")
client = FeedOracleClient("YOUR_API_KEY")
print(client.macro())
Postman Collection
Import directly into Postman:
https://feedoracle.io/docs/postman.json