2014-04-04 13:25:42 -07:00
|
|
|
pydiscourse
|
2014-04-04 23:09:23 -07:00
|
|
|
------------
|
|
|
|
|
A Python library for the Discourse API.
|
|
|
|
|
Its pretty basic right now but you need to start somewhere.
|
2014-04-04 13:25:42 -07:00
|
|
|
|
2014-04-04 23:09:23 -07:00
|
|
|
Examples
|
|
|
|
|
-----------
|
|
|
|
|
Create a client connection to a Discourse server::
|
2014-04-04 14:27:33 -07:00
|
|
|
|
2014-04-04 23:09:23 -07:00
|
|
|
from pydiscourse.client import DiscourseClient
|
|
|
|
|
client = DiscourseClient('http://example.com', api_username='username', api_key='areallylongstringfromdiscourse')
|
2014-04-04 14:27:33 -07:00
|
|
|
|
2014-04-04 23:09:23 -07:00
|
|
|
Get info about a user::
|
|
|
|
|
|
|
|
|
|
user = client.user('eviltrout')
|
|
|
|
|
print user
|
2014-04-04 14:27:33 -07:00
|
|
|
|
2014-04-04 23:09:23 -07:00
|
|
|
user_topics = client.topics_by('johnsmith')
|
|
|
|
|
print user_topics
|
2014-04-04 14:27:33 -07:00
|
|
|
|
2014-04-04 23:09:23 -07:00
|
|
|
Create a new user::
|
2014-04-04 14:27:33 -07:00
|
|
|
|
2014-04-04 23:09:23 -07:00
|
|
|
user = client.create_user('The Black Knight', 'blacknight', 'knight@python.org', 'justafleshwound')
|
2014-04-04 14:27:33 -07:00
|
|
|
|
2014-04-04 23:09:23 -07:00
|
|
|
Command line
|
|
|
|
|
----------------
|
2014-04-04 14:27:33 -07:00
|
|
|
|
2014-04-04 23:09:23 -07:00
|
|
|
To help experiment with the Discourse API, pydiscourse provides a simple command line client::
|
|
|
|
|
|
|
|
|
|
pydiscourse --host=http://yourhost --api-username=system --api-key=API_KEY latest_topics
|
|
|
|
|
pydiscourse --host=http://yourhost --api-username=system --api-key=API_KEY topics_by johnsmith
|
|
|
|
|
pydiscourse --host=http://yourhost --api-username=system --api-key=API_KEY user eviltrout
|