Discourse API Documentation


(sleep) #116

HI! I write a php fucntion to test this upload api.

public function upload_file($user) {
  $url = 'http://hostname/uploads?api_key=api_key&api_username=api_username';
  $poststr = http_build_query(array('username' => $user, 'type' => 'image', 'file' => '/uploads/file/filename', 'synchronous' => 'true');
  $data = _curl($url, $poststr));  // _curl() : a custom function 
  return $data;

$data is empty. Why is it empty? It’s not supposed to return a url.

if I remove a parammeter : synchronous, it will return the response of “{“success”:“OK”}”.


I’m trying to locate an endpoint to list all users? I’ve searched through this thread and haven’t found anything… I had a look at discourse/routes.rb at master · discourse/discourse · GitHub but no luck there – I’m not very literate with Ruby so I might be missing it.

(Kane York) #118

You have to export the user list from /admin/users/list/active, on the upper right.


@riking Thanks ! but do you mean there is no programmatic way to do this? I have to do this manually everytime I want the data? E.g. I can’t request /users/list/new.json ?

I’m also similarly looking for data on posts… Thanks for the help!

(Kane York) #120

If you’re looking for analytics, check out the Data Explorer. You can write SQL queries to execute on the database.

(Miguel Ángel López Vicente) #121

How I can get all users that replied a topic?


I am trying to connect discourse with wordpress/woocommerce using zapier to set the trust level = 2 of a user after his successful purchase.

wp discourse i installed and SSO enabled.

The problem is, that woocommerce transactions only provide the email address of the buyer, but not the user_id from the forum. Is there a way to retrieve the user_id based on the email address?

(Lennart) #123

Is there a method to change a users password through the API?
You can change the username, email addres, but pass not?


(Tuan Anh Tran) #124

How do I create a new topic under a category (say id 1) ?

From the document, it only takes title and raw as params

curl -X POST -d title="Title of my topic" -d raw="This is the body of my topic" http://localhost:3000/posts?api_key=test_d7fd0429940&api_username=test_user

(Blake Erickson) #125

There is an optional category flag:

(Zinda Xyz) #126

i can login with username and password using api but how can i login with Facebook/google accounts in api

also how to reset password link using username or email with api?

(Khoa Nguyen) #127

What is the recommended way to test Discourse API ? I’m writing an API wrapper for Discourse and hitting real API is just long.

(Blake Erickson) #128

What language are you writing the wrapper in?

I just have discourse running locally. Also you can stub out your responses so that they don’t run against an actual discourse instance for testing. This is what we do for the discourse_api project.

(Blake Erickson) #129

I’m not sure. It would probably be better if you used an API KEY though?

I would use the chrome developer tools and see what api calls are being made when you reset the password.

(Khoa Nguyen) #130

I’m writing a wrapper for node.js . (there is a discourse API for node.js but I disagree with its design pattern)

Are you using docker like official install instruction or using vagrant ?

I will run automate test on Travis CI so what’s your recommend ?

I’m not sure about this. I didn’t looks into Discourse source code for a longtime. Does Discourse’s API stable ? I want to test again a real Discourse instance for up-to-date API

(Blake Erickson) #131

I’m just using the development install. If it’s too slow to run locally you could always spin up an instance on Digital Ocean and run it against that.

Travis is a good choice. [quote=“thangngoc89, post:130, topic:22706”]
Does Discourse’s API stable ? I want to test again a real Discourse instance for up-to-date API

Well It’s not versioned, so yea something could change on you.

(Khoa Nguyen) #132

Last time I start Discourse’s vagrant image, it’s terrible slow. But I upgraded my PC since then. Let’s me try again.

Yeah. That’s the problem :frowning:

(Jdorweiler) #133

Can I change a user’s website link through the api?

(Blake Erickson) #134

You can submit a PUT request to the following URL:


and pass in the website value: “http://blog.username.com

(Jdorweiler) #135

curl -X PUT -d 'website=http://blog.username.com' http://discourse.example.com/users/<user_name>?api_key=XXXXXXX

Does that look right?