# Interact with discourse from Python?

**URL:** https://meta.discourse.org/t/interact-with-discourse-from-python/87543
**Category:** Development
**Created:** [May 15, 2018, 4:34pm UTC](https://meta.discourse.org/t/interact-with-discourse-from-python/87543 "2018-05-15T16:34:39Z")
**Posts on this page:** 1
**Showing post:** 20

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [March 4, 2026, 7:14pm UTC](https://meta.discourse.org/t/interact-with-discourse-from-python/87543/20 "2026-03-04T19:14:28Z")

</div>

> [@remidm](#):
>
> I’m also interested in getting data from discourse

You don’t always need to use someone else’s interface.

It’s not too troublesome to do this via the builtin requests library, and if you use something (e.g. Postman, which I already have set up) you can import our [API specification](http://docs.discourse.org/) to it and then have it generate code:

 ![image](https://global.discourse-cdn.com/meta/original/4X/3/8/0/38005cb274a9583c567f6e3abde996b2ab45cc84.png)

and then adapt that to your needs:

```python
import json
import pandas
import requests

url = "https://try.discourse.org/categories.json?include_subcategories=false"

payload = {}
headers = {
  'Accept': 'application/json'
}

response = requests.request("GET", url, headers=headers, data=payload)
response_data = json.loads(response.text)
data = pandas.DataFrame(response_data['category_list']['categories']).set_index('id')

```

now I have category information:

```plaintext
            name color text_color ... uploaded_background_dark topics can_vote
id ...                                                                                     
5 general 25AAE2 FFFFFF ... None [{'fancy_title': 'Testing dulu ya jangan di hi... NaN
4 videos 258af1 FFFFFF ... None [{'fancy_title': 'Ikan ganteng yang&rsquo;&rdq... NaN
86 calendar 12A89D FFFFFF ... None [{'fancy_title': 'Category Calendar demo topic... NaN
2 tech 444 FFFFFF ... None [{'fancy_title': 'Poll: What&rsquo;s your pref... NaN
1 discourse 00B355 FFFFFF ... None [{'fancy_title': 'Welcome to our demo!', 'id':... NaN
53 Topic Voting F7941D FFFFFF ... None [{'fancy_title': 'Is this topic worth voting f... True
6 gaming 800080 FFFFFF ... None [{'fancy_title': 'Impressions Games City Build... NaN
8 movies B22222 FFFFFF ... None [{'fancy_title': 'What&rsquo;s your all-time f... NaN
9 sports 0000FF FFFFFF ... None [{'fancy_title': 'Modernizing the antiquated b... NaN

[9 rows x 45 columns]

```

If you want to access protected information you’ll want to [use an API key](https://meta.discourse.org/t/create-and-configure-an-api-key/230124).

---

_[View the full topic](https://meta.discourse.org/t/interact-with-discourse-from-python/87543)._
