# Getting Markdown for a post using API

**URL:** https://meta.discourse.org/t/getting-markdown-for-a-post-using-api/324716
**Category:** Development
**Tags:** rest-api
**Created:** [September 3, 2024, 4:16pm UTC](https://meta.discourse.org/t/getting-markdown-for-a-post-using-api/324716 "2024-09-03T16:16:36Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![mcmcclur](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcmcclur/32/115456_2.png) [@mcmcclur](https://meta.discourse.org/u/mcmcclur)
#### Post date: [September 3, 2024, 4:16pm UTC](https://meta.discourse.org/t/getting-markdown-for-a-post-using-api/324716/1 "2024-09-03T16:16:36Z")

</div>

It’s easy to get all kinds of information about a post on a Discourse instance using the Discourse API. We can even get the entire text of a post as HTML in it’s “cooked” form. Is it possible, though, to get the original Markdown that was typed in to generate the post via the API?

---

<div class="post-metadata">

### Author: ![Heliosurge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/heliosurge/32/571810_2.png) [@Heliosurge](https://meta.discourse.org/u/Heliosurge)
#### Post date: [September 3, 2024, 4:18pm UTC](https://meta.discourse.org/t/getting-markdown-for-a-post-using-api/324716/2 "2024-09-03T16:18:26Z")

</div>

This #Customization > Theme component will add a raw button

> [@Raw Post Button](https://meta.discourse.org/t/raw-post-button/152542):
>
> discourse2Summary Raw Post Button will add a button to the post menu. When you click the button, you’ll get a modal / popover with the raw (markdown) version of the post.eyeglassesPreview [Preview on Discourse Theme Creator](https://discourse.theme-creator.io/theme/Discourse/raw-post-button)hammer_and_wrenchRepository Link [https://github.com/discourse/raw-post-button](https://github.com/discourse/raw-post-button)open_bookNew to Discourse Themes? [Beginner’s guide to using Discourse Themes](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966) Install this theme component Features Settings …

---

<div class="post-metadata">

### Author: ![mcmcclur](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcmcclur/32/115456_2.png) [@mcmcclur](https://meta.discourse.org/u/mcmcclur)
#### Post date: [September 3, 2024, 4:22pm UTC](https://meta.discourse.org/t/getting-markdown-for-a-post-using-api/324716/3 "2024-09-03T16:22:55Z")

</div>

> [@Heliosurge](#):
>
> This #Customization > Theme component will add a raw button

Thanks for the response. My question, though, is can I access the original Markdown _via the Discourse API_?

---

<div class="post-metadata">

### Author: ![Heliosurge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/heliosurge/32/571810_2.png) [@Heliosurge](https://meta.discourse.org/u/Heliosurge)
#### Post date: [September 3, 2024, 4:26pm UTC](https://meta.discourse.org/t/getting-markdown-for-a-post-using-api/324716/4 "2024-09-03T16:26:21Z")

</div>

I am not sure with the API but this is another method of getting raw post.

> [@Using AI to create Hide content bbcode wrapper](https://meta.discourse.org/t/using-ai-to-create-hide-content-bbcode-wrapper/321078/2):
>
> That’s very cool! The caveat, which you likely know, is that the text is available several ways since it’s just hidden with css. One is this post route: /posts/123/raw

And a topic with similar request.

> [@Raw Post Body for POST API](https://meta.discourse.org/t/raw-post-body-for-post-api/85128):
>
> Is there a way to view an existing post I’ve created and what that looks like if I want to use it for a a template when making a POST api request with the “raw” field? Thanks!

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [September 3, 2024, 10:19pm UTC](https://meta.discourse.org/t/getting-markdown-for-a-post-using-api/324716/6 "2024-09-03T22:19:11Z")

</div>

> [@mcmcclur](#):
>
> As far as I can tell from the discussion so far, the answer is  
> _ **No** , we cannot get the text of a post in Markdown form via the Discourse API_.

I think you are talking about the `topic/SLUG/id.json` endpoint?

If so, then by adding `?include_raw=true` to the endpoint the JSON for the posts in the topic will include raw.

---

<div class="post-metadata">

### Author: ![mcmcclur](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcmcclur/32/115456_2.png) [@mcmcclur](https://meta.discourse.org/u/mcmcclur)
#### Post date: [September 3, 2024, 11:48pm UTC](https://meta.discourse.org/t/getting-markdown-for-a-post-using-api/324716/7 "2024-09-03T23:48:42Z")

</div>

> [@sam](#):
>
> adding `?include_raw=true` to the endpoint

Yes, that does it exactly - thanks Sam!!

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [October 3, 2024, 11:49pm UTC](https://meta.discourse.org/t/getting-markdown-for-a-post-using-api/324716/8 "2024-10-03T23:49:03Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
