> ## Documentation Index
> Fetch the complete documentation index at: https://docs.metar.ws/llms.txt
> Use this file to discover all available pages before exploring further.

# Browser

> A minimal client for internal dashboards. Proxy the stream through your backend for public-facing products.

The native `WebSocket` API needs the key on the query string, since browsers can't set custom headers on a WebSocket upgrade request.

```html theme={null}
<script>
  const ws = new WebSocket(
      "wss://stream.metar.ws/v1/ws?key=mts_live_YOUR_KEY",
    );
  ws.onmessage = (ev) => {
      const msg = JSON.parse(ev.data);
      if (msg.type === "ack") {
            ws.send(JSON.stringify({ action: "subscribe", channels: ["sandbox.demo"] }));
      } else if (msg.type === "publication") {
            console.log(msg.data.station, msg.data.temp_c + "degC");
      }
  };
</script>
```

> [!WARNING]
>
> Anything shipped to a browser exposes your API key to whoever opens DevTools. Use browser connections for internal dashboards and demos; for public-facing products, proxy the stream through your backend instead.

> [card] [Python](https://docs.metar.ws/examples/python.md)
>
> The same client using websockets

> [card] [Node.js](https://docs.metar.ws/examples/nodejs.md)
>
> The same client using ws

> [card] [Go](https://docs.metar.ws/examples/go.md)
>
> The same client using gorilla/websocket

> [card] [Next: Best Practices](https://docs.metar.ws/best-practices.md)
>
> A checklist of practical tips gathered from across this reference.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.