A Python library for the Discourse API
Python Makefile
Clone or download
#13 Compare This branch is 87 commits ahead of tindie:master.
bennylope Merge pull request #12 from goetzk/patch-1
Increase minimum requests version
Latest commit 7793f3a Feb 15, 2018
Failed to load latest commit information.
docs Version bump 0.7.0 Sep 9, 2016
pydiscourse Merge branch 'master' into new-api-methods Nov 30, 2017
tests update test Sep 8, 2016
.gitignore move docs to more std docs/ Apr 22, 2014
.travis.yml Remove requirements file from travis.yml Apr 7, 2016
AUTHORS Version bump 0.7.0 Sep 9, 2016
CONTRIBUTING.rst Update CONTRIBUTING.rst Oct 6, 2017
HISTORY.rst Version bump 0.7.0 Sep 9, 2016
LICENSE Initial commit Apr 4, 2014
MANIFEST.in Update changelog to include in package description Apr 11, 2016
Makefile Update makefile Jun 13, 2016
README.rst Update README Apr 8, 2016
tox.ini Remove duplicate requests dependency in tox config Apr 8, 2016



Build Status

A Python library for working with Discourse.

This is a fork of the original Tindie version. It was forked to include fixes, additional functionality, and to distribute a package on PyPI.


  • Exceptional documentation
  • Support all supported Python versions
  • Provide functional parity with the Discourse API, for the currently supported version of Discourse (something of a moving target)

The order here is important. The Discourse API is itself poorly documented so the level of documentation in the Python client is critical.


pip install pydiscourse


Create a client connection to a Discourse server:

from pydiscourse import DiscourseClient
client = DiscourseClient(

Get info about a user:

user = client.user('eviltrout')
print user

user_topics = client.topics_by('johnsmith')
print user_topics

Create a new user:

user = client.create_user('The Black Knight', 'blacknight', 'knight@python.org', 'justafleshwound')

Implement SSO for Discourse with your Python server:

def discourse_sso_view(request):
    payload = request.GET.get('sso')
    signature = request.GET.get('sig')
    nonce = sso_validate(payload, signature, SECRET)
    url = sso_redirect_url(nonce, SECRET, request.user.email, request.user.id, request.user.username)
    return redirect('http://discuss.example.com' + url)

Command line

To help experiment with the Discourse API, pydiscourse provides a simple command line client:

export DISCOURSE_API_KEY=your_master_key
pydiscoursecli --host-http://yourhost --api-user-system latest_topics
pydiscoursecli --host-http://yourhost --api-user-system topics_by johnsmith
pydiscoursecli --host-http://yourhost --api-user-system user eviltrout