A Python library for the Discourse API
Project description
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.
Goals
Provide functional parity with the Discourse API, for the currently supported version of Discourse (something of a moving target)
Support all supported Python versions
Document API
Examples
Create a client connection to a Discourse server:
from pydiscourse.client 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', 'knight@python.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)
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pydiscourse-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41f94279d83bae01050d94a0fa666e0e497e189cd261fc6190c057d64255a430 |
|
MD5 | 4b1ad023136c3663a16406edc871441d |
|
BLAKE2b-256 | 8e82f239ed4a809d1a79d2345de7b34686c2a853bf7f7262bb8e014424332c46 |