Integrations
Code examples
Start integrating with Python and JavaScript.
Set ECLIPSE_API_KEY on your server. The Python example requires requests; the JavaScript example uses Node.js 20+. These examples read a snapshot and inspect responses. Follow the signal-feed pagination guidance before building an ingestion loop.
Python
import os
import requests
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
BASE = "https://www.eclipse.trade/api/v1"
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['ECLIPSE_API_KEY']}"
# Retry transient failures for read requests only.
retry = Retry(total=3, backoff_factor=1, status_forcelist=[502, 503, 504],
allowed_methods=["GET"], respect_retry_after_header=True)
session.mount("https://", HTTPAdapter(max_retries=retry))
response = session.get(f"{BASE}/state", timeout=20)
response.raise_for_status()
board = response.json()
print("snapshot time:", board["as_of"])
for asset in board["assets"]:
print(asset["ticker"], asset["signals"].get("trend_oracle"))
# Inspect one page. This is not a complete event-ingestion loop.
response = session.get(f"{BASE}/signals", params={"limit": 50}, timeout=20)
response.raise_for_status()
page = response.json()
print("quota left:", response.headers.get("X-RateLimit-Remaining"))
for signal in page["signals"]:
print(signal["id"], signal["ticker"], signal["direction"])
if page["pagination"]["has_more"]:
print("More pages remain. Do not advance since to next_cursor yet.")JavaScript / TypeScript
const KEY = process.env.ECLIPSE_API_KEY
if (!KEY) throw new Error('Set ECLIPSE_API_KEY on your server')
const BASE = 'https://www.eclipse.trade/api/v1'
const res = await fetch(BASE + '/confluence?timeframe=4h&min_agree=4', {
headers: { Authorization: 'Bearer ' + KEY },
signal: AbortSignal.timeout(20_000),
})
if (!res.ok) {
const detail = await res.text()
throw new Error('Eclipse HTTP ' + res.status + ': ' + detail)
}
console.log('quota left:', res.headers.get('X-RateLimit-Remaining'))
const { as_of, results } = await res.json()
console.log('snapshot time:', as_of)
for (const asset of results) {
// Agreement is not a probability of profit.
console.log(asset.ticker, asset.agree + '/' + asset.total_reporting, asset.votes)
}