As I’ve said, if you want to get Twitch Chat you need to connect to IRC and receive it as it happens. There are no API endpoints for retrieving historic chat messages.
And even if you do capture chat as it happens that still doesn’t relate to viewership as that’s just the users connected to chat and sending messages and may not mean they are a viewer, and similarly there will be viewers who are not connected to chat.