# Python Twisted Client

**URL:** https://meta.discourse.org/t/python-twisted-client/24573
**Category:** Extras
**Created:** [January 29, 2015, 4:06pm UTC](https://meta.discourse.org/t/python-twisted-client/24573 "2015-01-29T16:06:42Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![anouk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/anouk/32/115300_2.png) [@anouk](https://meta.discourse.org/u/anouk)
#### Post date: [January 29, 2015, 4:06pm UTC](https://meta.discourse.org/t/python-twisted-client/24573/1 "2015-01-29T16:06:42Z")

</div>

Hey all!

Just uploaded a Discourse API wrapper for Twisted/Python.  
It includes some tests and an example to help you get started. You can find it [right here](https://github.com/theGeoffrey/txDiscourse). Have fun!

(for those wondering Twisted is an event-driven network programming framework written in Python. [Check it out!](https://twistedmatrix.com/trac/)

> # txDiscourse - Twisted Discourse Client

> Discourse API wrapper written for [Twisted](https://twistedmatrix.com/trac/), the event-driven network programming framework written in Python.

> ## Installation:

> ```
> pip install txDiscourse
> 
> ```

> ### Requirements:

> - Twisted \> 14.0.0
> - treq==0.2.1
> - service-identity==14.0.0

> For development/testing:
> 
> - nosetests == 1.3.4

> ### Try it out!
> 
> Add your Discourse Hostname and Api Key and run:

> ```
> python txDiscourse/example.py
> 
> ```

> this should give you your latest posts.

> ### Usage:

> Create a new client and give it your [discourse host, api key and username](https://meta.discourse.org/t/using-discourse-api/17587):

> ```
> from txDiscoure import DiscourseClient
> 
> ```

> ```
> client = DiscourseClient(host, api_key, username)
> 
> ```

> Get latest topics:

> ```
> client.latest_topics
> 
> ```

> Create a new topic:

> ```
> client.create_topic('title', 'text text text')
> 
> ```

> Get all topics created:

> ```
> client.topic_by('username')
> 
> ```

> returns a list of topics in a json string.

> For more examples check out the test\_api\_calls.

> ### Testing:

> At the moment tests only cover topics. To run tests:

> ```
> export DC_HOST="test.discourse.com"
> export DC_API_KEY="1234567890"
> export DC_USERNAME="system"
> nosetest txDiscourse.test_api_calls
> 
> ```

> ### License

> Copyright 2015 Anouk Ruhaak

> Licensed under the Apache License, Version 2.0 (the “License”);  
> you may not use this file except in compliance with the License.  
> You may obtain a copy of the License at

> ```
> http://www.apache.org/licenses/LICENSE-2.0
> 
> ```

> Unless required by applicable law or agreed to in writing, software  
> distributed under the License is distributed on an “AS IS” BASIS,  
> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
> See the License for the specific language governing permissions and  
> limitations under the License.

---

<div class="post-metadata">

### Author: ![lightyear](https://avatars.discourse-cdn.com/v4/letter/l/848f3c/32.png) [@lightyear](https://meta.discourse.org/u/lightyear)
#### Post date: [January 29, 2015, 4:55pm UTC](https://meta.discourse.org/t/python-twisted-client/24573/2 "2015-01-29T16:55:01Z")

</div>

You eventually published it! Nice!

---

<div class="post-metadata">

### Author: ![clay](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/clay/32/102156_2.png) [@clay](https://meta.discourse.org/u/clay)
#### Post date: [January 29, 2015, 5:35pm UTC](https://meta.discourse.org/t/python-twisted-client/24573/3 "2015-01-29T17:35:18Z")

</div>

Hmm, looks like `treq` and Python 3.4 don’t play well together.

---

<div class="post-metadata">

### Author: ![anouk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/anouk/32/115300_2.png) [@anouk](https://meta.discourse.org/u/anouk)
#### Post date: [January 29, 2015, 8:05pm UTC](https://meta.discourse.org/t/python-twisted-client/24573/4 "2015-01-29T20:05:33Z")

</div>

> [@clay](#):
>
> Hmm, looks like treq and Python 3.4 don’t play well together.

Nope. Forgot to mention: up to 2.7 only!
