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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.622s · 21.1MB
glibcpy 3.10–3.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])
Errors
Common errors & fixes
ImportError: cannot import name 'DiscourseError' from 'pydiscourse'
DiscourseError is not exported from the top-level package.
fixUse 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.
fixUse 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