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

# Indices

> Live updates over WebSocket for all NGX market indices.

```
wss://api.ngnmarket.com/v1/ws/indices
```

Pushes every NGX index whenever any of their values change, with the same fields [`GET /indices`](/api-reference/indices/list) returns per index. No query parameters, so every connection receives all indices, including ones without a price yet. Those fields just come back `null` instead of the index being left out.

```
wss://api.ngnmarket.com/v1/ws/indices?api_key=ngm_live_YOUR_KEY
```

<CodeGroup>
  ```javascript Browser theme={null}
  const ws = new WebSocket(
    'wss://api.ngnmarket.com/v1/ws/indices?api_key=ngm_live_YOUR_KEY'
  );

  ws.onmessage = (event) => {
    const msg = JSON.parse(event.data);
    console.log(msg.type, msg.indices);
  };
  ```

  ```javascript Node.js theme={null}
  import WebSocket from 'ws';

  const ws = new WebSocket(
    'wss://api.ngnmarket.com/v1/ws/indices?api_key=ngm_live_YOUR_KEY'
  );

  ws.on('message', (data) => {
    const msg = JSON.parse(data.toString());
    console.log(msg.type, msg.indices);
  });
  ```

  ```python Python theme={null}
  import asyncio
  import json
  import websockets

  async def main():
      url = "wss://api.ngnmarket.com/v1/ws/indices?api_key=ngm_live_YOUR_KEY"
      async with websockets.connect(url) as ws:
          async for raw in ws:
              msg = json.loads(raw)
              print(msg["type"], msg["indices"])

  asyncio.run(main())
  ```
</CodeGroup>

## Message format

`snapshot` arrives once on connect with every index's current value. `update` arrives whenever any index changes, and always carries the full list, not just the one that moved.

```json theme={null}
{
  "type": "update",
  "indices": [
    {
      "id": 5,
      "symbol": "NGX30",
      "index_name": "NGX 30",
      "description": "Tracks the top 30 companies by market capitalization and liquidity.",
      "created_at": "2025-11-03T09:21:11.000Z",
      "updated_at": "2026-04-21T10:44:15.000Z",
      "current_value": 4820.15,
      "prev_close": 4807.75,
      "price_change": 12.40,
      "price_change_percent": 0.26,
      "change_7d_percent": 0.23,
      "change_52w_percent": 82.91,
      "change_ytd_percent": 57.99,
      "high_52wk": 4950.00,
      "high_52wk_date": "2026-05-11",
      "low_52wk": 2705.00,
      "low_52wk_date": "2025-07-26",
      "last_updated": "2026-08-21T11:40:00.000Z"
    }
  ]
}
```

See [Errors](/websocket/errors) for connection-level error codes. This channel takes no parameters, so nothing about it specifically can fail.
