# Reverse engineer the Discourse API

**URL:** https://meta.discourse.org/t/reverse-engineer-the-discourse-api/20576
**Category:** Integrations
**Tags:** rest-api, how-to
**Created:** [September 29, 2014, 1:22am UTC](https://meta.discourse.org/t/reverse-engineer-the-discourse-api/20576 "2014-09-29T01:22:40Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [September 29, 2014, 1:22am UTC](https://meta.discourse.org/t/reverse-engineer-the-discourse-api/20576/1 "2014-09-29T01:22:40Z")

</div>

Discourse is backed by a complete JSON api. Anything you can do on the site you can also do using the JSON api.

The API is documented at [docs.discourse.org](https://docs.discourse.org). You can also use the [discourse\_api](https://github.com/discourse/discourse_api) Ruby gem as a client library. However, not every endpoint is documented.

To determine how to do something with the JSON API here are some steps you can follow.

### Example: recategorize a topic.

- Go to a topic and start editing a category:

 ![image](https://global.discourse-cdn.com/meta/original/4X/3/b/e/3be9c7a1d786db61c7769cba00a53806a76fd0cb.png)

- Open Chrome dev tools, switch to the Network tab, select the Fetch/XHR filter:

 ![image](https://global.discourse-cdn.com/meta/original/4X/b/2/5/b25a8e627f401fd59958180f59432139fe303c37.png)

- Perform the operation

 ![image](https://global.discourse-cdn.com/meta/original/4X/d/e/f/def9a6fbe11f26d8be158097a526ea5e4bf3221f.png)

- The request data will be shown under the “Payload” tab

![image](https://global.discourse-cdn.com/meta/original/4X/3/a/9/3a9316f4905f948a6c2bb3bde8418dca058bada7.png)

- Look at preview as well to figure out the results

![](https://global.discourse-cdn.com/meta/original/3X/a/f/af1560423c5cbee00f1f5fe4685d7b798c52494f.png)

- You now have all the info you need.

1. The endpoint is `https://try.discourse.org/t/online-learning/108.json`

2. Payload is passed using a `PUT`

3. The parameter sent is: `category_id: 5`

Equipped with this information you can make your own calls using your favorite programming language. All you need to do is add your `Api-Username` and `Api-Key` to the request headers. (See [Discourse REST API Documentation](https://meta.discourse.org/t/discourse-api-documentation/22706) for details about how to formulate a curl request to the Discourse API.)

API credentials can be generated from the admin panel at `/admin/api/keys`:

 ![image](https://global.discourse-cdn.com/meta/original/4X/5/3/a/53ae25e4cf1e040d8ef534c03e06f8aba6006aa1.png)
