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

# streamMarketSummary

> Python SDK reference for streamMarketSummary.

Stream market summary updates for a specific market and yield JSON objects.

<ParamField path="market_id" type="object" required>
  The market identifier
</ParamField>

<ResponseField name="yields" type="object" required>
  Dictionary containing market summary data, or None on error
</ResponseField>

**Raises**

* **ValueError** — If API\_SERVER\_URL environment variable is not set

**Example**

```python theme={null}
>>> import os
>>> os.environ["API_SERVER_URL"] = "http://localhost:8080"
>>> async for summary in streamMarketSummary(market_id=1):
...     print(summary["openInterest"])
```

```python theme={null}
async def streamMarketSummary(market_id: Union[str, int]) -> AsyncIterator[Optional[Dict[str, Any]]]:
    base_url = os.getenv('API_SERVER_URL')
    if not base_url:
        raise ValueError('API_SERVER_URL environment variable not set')
    async with httpx.AsyncClient() as session:
        client = PerpetualsClient(base_url=base_url, session=session)
        try:
            async for market_summary in client.stream_market_summary(market_id):
                market_summary_dict = MessageToDict(market_summary, always_print_fields_with_no_presence=True)
                market_summary_dict = _filter_executable_depth(market_summary_dict)
                yield market_summary_dict
        except Exception as e:
            print(f'Error streaming market summary: {e}')
            print('\nTroubleshooting:')
            print('  - Is the server running?')
            print('  - Is this a valid market ID in the database?')
            print('  - Check network connectivity')
            yield None
```
