# Signalview Agent API

Read-only access to Signalview's Hyperliquid perps signals for AI agents and bots.
Every call is ed25519-signed and hash-chained when it's issued, and resolved against real
candles afterwards, so its track record can't be edited after the fact.

Signals are information, not financial advice. Returns are unlevered price moves
before fees and funding.

## MCP (Claude, ChatGPT, Cursor, any MCP client)

Remote MCP server, Streamable HTTP (stateless JSON):

```
https://www.signalview.xyz/mcp
```

Claude Code: `claude mcp add --transport http signalview https://www.signalview.xyz/mcp`

| Tool | What it returns |
|---|---|
| `get_call` | Current signed call for a market + style: action, entry, stop, target, leverage hint, status |
| `get_ledger` | Past calls with outcomes (tp / sl / superseded / expired), newest first |
| `get_track_record` | Win rate and returns of resolved calls (live, not backtest) |
| `verify_call` | Hash, signature and chain-link check for one call |
| `list_signals` / `get_signal` | Published community signals with backtest + live stats |

## REST

Base: `https://www.signalview.xyz/api/signals`

| Request | Purpose |
|---|---|
| `?op=agent_call&symbol=BTC&style=swing[&signal_id=sig_x]` | current call (CDN-cached 60 s) |
| `?op=agent_ledger[&symbol=&style=&signal=dna\|sig_x&limit=1..200&before_seq=]` | ledger + track record |
| `?op=agent_record[&symbol=&style=&signal=]` | track record over the last 1000 calls |
| `?op=agent_verify&id=call_x` | verify one entry |
| `?op=agent_pubkey` | signing key + current chain head |

Symbols: any listed Hyperliquid perp (`BTC`, `ETH`, `SOL`, `xyz:TSLA` ...).
Styles: `flash`=15m, `scalp`=1h, `swing`=4h, `position`=1d, `macro`=3d.

## Call object (`signalview.call/v1`)

```json
{
  "schema": "signalview.call/v1", "seq": 412, "prev": "<hash of entry 411>",
  "stream": "SOLUSDT|scalp|dna", "symbol": "SOLUSDT", "coin": "SOL", "venue": "hyperliquid",
  "style": "scalp", "tf": "1h", "signal_id": null, "signal_name": "Perps DNA",
  "action": "short", "entry_ref": 89.19, "stop_loss": 90.1648, "take_profit": 87.8061,
  "sl_pct": 0.010929, "tp_pct": 0.015516, "leverage_hint": 16.05,
  "confidence": 0.5525, "regime": "trend_down", "score": -0.209266,
  "bar_time": "2026-11-08T02:00:00+00:00", "issued_at_ms": 1794108731144,
  "valid_until_ms": 1794112331144, "resolve_by_ms": 1794216731144
}
```

- A new call is issued only when a stream's action changes. `flat` closes the previous call.
- **Only enter if `now <= valid_until_ms`** (one signal bar after issue). The API's `status`
  is `actionable` in that window. Responses are cached, so check the timestamp yourself too.
- A call resolves as `tp` / `sl` (first touch in candles that open after issue; both in one
  candle counts as `sl`), `superseded` (closed at the next call's price), or `expired`
  (closed at market after 30 signal bars).
- `leverage_hint` is the model's sizing hint, not a recommendation. Cap it yourself.

## Verifying

Each entry has `body` (the exact signed string), `hash`, `sig`, `id`:

1. `sha256(body) == hash`, and `id == "call_" + hash[:24]`
2. `ed25519_verify(pubkey, body_utf8_bytes, sig)` using `?op=agent_pubkey`
3. `json.loads(body).prev` equals the hash of entry `seq - 1` (64 zeros for seq 1)

Hash `body` exactly as returned. Don't re-serialise it.

```python
import hashlib, json, requests
from nacl.signing import VerifyKey
B = "https://www.signalview.xyz/api/signals"
pk = requests.get(B, params={"op": "agent_pubkey"}).json()["pubkey"]
e = requests.get(B, params={"op": "agent_ledger", "limit": 1}).json()["entries"][0]
assert hashlib.sha256(e["body"].encode()).hexdigest() == e["hash"]
VerifyKey(bytes.fromhex(pk)).verify(e["body"].encode(), bytes.fromhex(e["sig"]))
```

## Trading a call

You execute through your own Hyperliquid account. The API never sees your keys.
To support Signalview, approve the builder fee once (`approveBuilderFee`, max 0.1%)
and attach the builder to your orders:

```json
"builder": {"b": "0x7c7f5Fab1e78a08274a2f2a36C4E7dD3557C9cfa", "f": 100}
```

(`f` is in tenths of a basis point: 100 = 0.1%.) Prefer a hosted agent instead?
Signalview runs non-custodial agents that trade these signals: https://www.signalview.xyz/agents
