Read public chat channel content from API

AI-generated summary

The discussion revolves around accessing public chat channel content via the Discourse API. Leo_Wong asks for documentation on how to retrieve chat channel data. Fairies-Feast points to a relevant topic for guidance. j.jaffeux clarifies that there is no official API documentation for chat at the moment, but provides the endpoints for retrieving channel and message data, including query parameters like fetch_from_last_read, page_size, and direction. jwilkey inquires about posting to a dynamic channel as a specific user, noting the limitations of webhooks. jwilkey later resolves the issue, sharing a curl command that uses the /chat/:id.json endpoint with Api-Key and Api-Username headers to post messages as a particular user, though it’s noted as unofficial.

Hello, is there any document that explains how to access the chat channel from the API? thank you

You could try looking at this topic.

We don’t have any official API documentation for chat ATM.

To get the channel information the endpoint is: /chat/api/channels/:id.json

If you want to access the messages: /chat/api/channels/:id/messages.json with available params being:

fetch_from_last_read=true
page_size=10
target_message_id=23323
direction=past/future

Is it possible to POST to a dynamic channel as a particular user? I have seen the web hooks configuration, but it appears that only works for a single existing channel acting as the system user.

I am using my instance as the backend for my platform’s community features and am interested in leveraging chat since that seems more appropriate than configuring Topics length and rate limit to allow for short form communications.

Typed too soon, I figured it out, but I’m guessing this is “unofficial”

curl --location 'https://MY_DISCOURSE.com/chat/4.json' \
--header 'Content-Type: application/json' \
--header 'Api-Key: THE_KEY' \
--header 'Api-Username: THE_ACTING_USER' \
--data '{ "message": "My great chat message!"}'