Skip to main content

Quickstart

This guide reads the current signed BTC/USD update and opens a WebSocket stream for BTC, ETH, and SOL.

1. Read discovery

curl https://api.marking.fyi/.well-known/marking.json

The discovery document includes the public API URL, supported payment networks, authority keys, feed-signing certificates, and revocations.

2. Read latest signed state

curl https://api.marking.fyi/v1/feeds/btc-usd/latest

The response is a signed envelope:

{
"payload": {
"schema": "marking.feed.v2",
"feedId": "btc-usd",
"sequence": "219870676620297556",
"price": "76524.6"
},
"keyId": "feed-key...",
"algorithm": "EdDSA",
"signature": "..."
}

3. Stream from a server

Keep your Marking API key in a server-side secret manager.

import WebSocket from "ws";

const feeds = ["btc-usd", "eth-usd", "sol-usd"];
const socket = new WebSocket(
`wss://api.marking.fyi/v1/streams?feedIds=${feeds.join(",")}&format=json`,
{
headers: {
authorization: `Bearer ${process.env.MARKING_API_KEY}`,
},
},
);

socket.on("message", (raw) => {
const message = JSON.parse(raw.toString());
if (message.type === "update" || message.type === "snapshot") {
console.log(message.update.payload.feedId, message.update.payload.price);
}
});

Browser note: native browser WebSockets cannot set an Authorization header. Browser apps should connect through their own backend or BFF. Do not put durable API keys in browser JavaScript or URLs.

4. Verify before acting

Before using an update in an automated workflow:

  1. Fetch discovery.
  2. Verify the authority signature on the feed-key certificate.
  3. Verify the feed key is authorized for the feed and not revoked.
  4. Verify the update signature.
  5. Enforce freshness, feed ID, and sequence continuity.