How to Download Images from Posts via API

Hi guys,
I wonder how to download images from new posts via API.

Assume someone comments on a topic and adds a new post with in image.

I am able to get the post via Discourse API Docs

Then I see the “Raw” item in the response. Example:
Raw Discourse

I assume “srRI0NdOWeF3ime6IZs78wc0iMP” is the ID of the image. How I am able to download this image from the API?

My goal is to take posts with images from Discourse and repost them on Twitter.

A simple way is to look at the cooked post which has the url.

2 Likes

Hmm, I was hoping to get something more structured. Ideally links to all the attachments in a variable. But yea, extracting the /original/ URL from the “cooked” variable is an option.