> For the complete documentation index, see [llms.txt](https://pycai.gitbook.io/welcome/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pycai.gitbook.io/welcome/examples/parse-chat.md).

# Parse Chat

Showing the entire chat

{% tabs %}
{% tab title="Sync" %}
{% code lineNumbers="true" %}

```python
from characterai import PyCAI

client = PyCAI('TOKEN')

history = client.chat.get_history('HISTORY_ID')

for h in history['messages']:
    name = h['src_char']['participant']['name']
    text = h['text']

    print(f'{name}: {text}')
```

{% endcode %}
{% endtab %}

{% tab title="Async" %}
{% code lineNumbers="true" %}

```python
import asyncio
from characterai import PyAsyncCAI

async def main():
    client = PyAsyncCAI('TOKEN')

    history = await client.chat.get_history('HISTORY_ID')

    for h in history['messages']:
        name = h['src_char']['participant']['name']
        text = h['text']

        print(f'{name}: {text}')

asyncio.run(main())
```

{% endcode %}
{% endtab %}
{% endtabs %}
