Registry / http-networking / pydiscourse

pydiscourse

JSON →
library1.7.0pypypi✓ verified 86d ago

A Python client library for the Discourse API. Allows interacting with a Discourse forum programmatically: create topics, posts, users, groups, etc. Latest version 1.7.0 adds Python 3.12 support. Maintenance ongoing, releases are sporadic.

pip install pydiscourse
INSTALL
IMPORT
SIG · PYDISCOURSE
P
pydiscourse
http-networkingpythonv1.7.0
Install
2.1s avg
Import
589ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.7.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.622s · 21.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.1s · import 0.556s · 22MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DiscourseClient
from pydiscourse import DiscourseClient
DiscourseError
from pydiscourse.exceptions import DiscourseError
from pydiscourse import DiscourseError
DiscourseError is in pydiscourse.exceptions, not top-level.

Initialize client with environment variables and fetch latest topics.

import os from pydiscourse import DiscourseClient client = DiscourseClient( host=os.environ.get('DISCOURSE_HOST', 'https://forum.example.com'), api_username=os.environ.get('DISCOURSE_API_USER', 'system'), api_key=os.environ.get('DISCOURSE_API_KEY', '') ) # Get latest topics latest = client.latest_topics() print(latest[:2])
Debug
Known issues
gotchaThe constructor expects `api_username` and `api_key` as keyword arguments; positional usage was common before v1.6.0 and may break if arguments are passed positionally.
fix
Always pass host, api_username, api_key as keyword arguments.
affects: >=1.6.0
deprecatedPython 2.7, 3.4, 3.5 support dropped in v1.2.0. Python 3.7 dropped in v1.5.0.
fix
Use Python 3.8+ (3.12 recommended).
affects: >=1.2.0
gotchaThe `requests` library is required and must be installed separately if not automatically pulled.
fix
pip install requests
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'DiscourseError' from 'pydiscourse'
DiscourseError is not exported from the top-level package.
fix
Use from pydiscourse.exceptions import DiscourseError
TypeError: __init__() takes 1 positional argument but 3 were given
Passing host, api_username, api_key as positional arguments instead of keyword arguments.
fix
Use DiscourseClient(host='...', api_username='...', api_key='...')
Upgrade
Version history
1.7.0latest on PyPI · released Apr 16, 2024
Audit
Dependencies
requestsrequiredHTTP client for Discourse API calls
Agent activity
23 hits · last 30 days
node
22
OpenAI (training)
1
Resources
pydiscourse — pip install pydiscourse · libregistry