Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
DocsQuickstart

Quickstart

Issue a key and make your first REST call in a few minutes, then stream over WebSocket on a paid plan or a trial.

Open .md
  1. Get an API key

    Sign up (verify your email if asked), then open Dashboard → API key and reveal the key to copy it. If an older key cannot be revealed, keep using your saved copy or contact support before replacing it.

  2. Authenticate

    SurfaceSend the key as
    RESTx-api-key: <YOUR_API_KEY> header on every request
    WebSocketwss://stream.tickerlayer.com/?apiKey=<YOUR_API_KEY> on the upgrade URL (Connection)

    Servers, native apps, curl and Postman need nothing more. A browser app can call REST only from an approved origin: contact us to allowlist your domain. Full guide: Authentication.

  3. Make your first REST call

    The latest BTC/USD quote:

    curl -sS "https://api.tickerlayer.com/crypto/quote/BTCUSD" \
      -H "x-api-key: <YOUR_API_KEY>"
    Response 200
    {
      "symbol": "BTCUSD",
      "bid": 84210.12,
      "ask": 84210.45,
      "bid_size": 1.2,
      "ask_size": 0.8,
      "timestamp": 1743512400000
    }
  4. Open a WebSocket

    WebSocket comes with the Individual and Business plans (Perpetuals streams on Business). On the Free plan the connection is refused with 403 and WS_NOT_INCLUDED; request a 7-day trial from the dashboard, under Plan & access.

    Connect, wait for the ready frame, then subscribe. The first frame is always { "type": "system", "event": "ready", "ts": <unix_ms> }.

    Node.js
    const key = "<YOUR_API_KEY>";
    const ws = new WebSocket(
      "wss://stream.tickerlayer.com/?apiKey=" + encodeURIComponent(key)
    );
    
    ws.addEventListener("message", (ev) => {
      const msg = JSON.parse(String(ev.data));
      if (msg.type === "system" && msg.event === "ready") {
        ws.send(JSON.stringify({
          action: "subscribe",
          channels: ["crypto.quotes"],
          symbols: ["BTCUSD"],
        }));
        return;
      }
      console.log(msg); // quote | trade | system | error
    });

Next steps

TickerLayer

Developer-friendly market data APIs for REST and WebSocket integrations, with real-time and historical access across stocks, forex, crypto, indices, ETFs, commodities, bonds and 24/7 perpetual futures.

TickerLayer provides derived, indicative market data for informational and technical use only. We are not affiliated with any exchange, issuer, broker, trading venue, or listed company unless expressly stated. We do not provide investment advice, execute trades, manage funds, or facilitate financial transactions. Data may be delayed, inaccurate, or different from official market prices. Perpetual futures data is a calculated composite of third-party derivatives markets: it is not the price of any underlying, carries no rights in any underlying, and we do not list, offer, or trade any contract. Futures CFDs are reference prices we calculate with our own methodology for futures contract months and roll series: they are not futures contracts and not the official settlement or closing price of any market. Benchmark and comparison content on this site reflects our own observations under a stated methodology during a stated window. It is not exchange data, implies no affiliation, endorsement, or certification by any exchange, index provider, or market data vendor, and is not a measure of execution quality or a guarantee of future performance. Third-party names and marks are used for identification only and belong to their respective owners. Redistribution is prohibited unless expressly authorized in writing.