A Python library for the Discourse API
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( 'http://example.com', api_username='username', api_key='areallylongstringfromdiscourse')
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', 'firstname.lastname@example.org', 'justafleshwound')
Implement SSO for Discourse with your Python server:
@login_required 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)
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
This is a potentially breaking change if you’re working with a significantly older Discourse deployment. It’s not entirely clear if header based authentication has been available since day 1 or was introduced in a recent version (you should be fine! … but caveat emptor).
- Adds new invitation methods
- Hard switch from query param based authorization to header-based authorization
- Added rate limiting support
- Added some support for user activation
- Add some PR guidance
- Add support for files in the core request methods
- Adds numerous new API controls, including:
- create_site_customization (theme)
- Place request parameters in the request body for POST and PUT requests. Allows larger request sizes and solves for URI Too Large error.
- Adds method to add user to group by user ID
- Adds badges functionality
- Adds initial groups functionality
- SSO functionality fixes
- Fix how empty responses are handled
- Added method to unsuspend suspended user
- Inital fork, including gberaudo’s changes
- Packaging cleanup, dropping Python 2.6 support and adding Python 3.5, PyPy, PyPy3
- Packaging on PyPI
All pre-PyPI development
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size pydiscourse-1.0.0-py2.py3-none-any.whl (14.3 kB)||File type Wheel||Python version py2.py3||Upload date||Hashes View|
|Filename, size pydiscourse-1.0.0.tar.gz (15.0 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for pydiscourse-1.0.0-py2.py3-none-any.whl