Skip to main content

A Python library for the Discourse API

Project description

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.

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 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydiscourse-0.3.1.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydiscourse-0.3.1-py2.py3-none-any.whl (10.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pydiscourse-0.3.1.tar.gz.

File metadata

  • Download URL: pydiscourse-0.3.1.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pydiscourse-0.3.1.tar.gz
Algorithm Hash digest
SHA256 dc99d01cc6d17edaed5eb47c65e4ee5c8e5a32565c632a8566aeb7ea80e4054c
MD5 2795e68b55a00609df6e89ba5aa8c114
BLAKE2b-256 b42f9cb05875288b06640f8b72b91bba811d69a0d5b4b48ed8e0e41e9d688252

See more details on using hashes here.

File details

Details for the file pydiscourse-0.3.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pydiscourse-0.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 717e6199f3a84274dfbf33b8ae2c5e223e7c56d1fcb97b67b709cda8ff4d8da7
MD5 8887074a0178022109ee4ef3d34d679b
BLAKE2b-256 f65f91b81a3127e7bb5ee8ea65a8ddb7c9967196777f4bb662e1c748f483cae0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page