Skip to main content

Meet Trollop

Trollop is a Python library for working with the Trello API.

Quick Start

A Trello connection is instantiated with your API key and a user’s oauth token:

In [1]: from trollop import TrelloConnection

In [2]: conn = TrelloConnection(<your developer key>, <user's oauth token>)

The connection object will automatically have a Member object attached, representing the user whose oauth token was used to connect:

In [3]: conn.me
Out[3]: <Member: me>

In [4]: conn.me.username
Out[4]: u'btubbs'

In the previous example no HTTP request was made until command 4, the access to conn.me.username. Trollop objects are lazy.

The connection object has methods for getting objects by their IDs:

In [5]: card = conn.get_card('4f2e454cefab2bbd4ea71b02')

In [6]: card.name
Out[6]: u'Build a Python Trello Library'

In [7]: card.desc
Out[7]: u'And call it Trollop.'

You can use normal Python introspection techniques to see the available attributes. They’ll mostly be named exactly as they are in the JSON returned from Trello:

In [13]: dir(card)
Out[13]:
['__class__',
 '__delattr__',
 '__dict__',
 '__doc__',
 '__format__',
 '__getattr__',
 '__getattribute__',
 '__hash__',
 '__init__',
 '__module__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__weakref__',
 '_conn',
 '_id',
 '_path',
 '_prefix',
 'badges',
 'board',
 'checkItemStates',
 'close',
 'closed',
 'desc',
 'labels',
 'list',
 'members',
 'name',
 'url']

The exact parsed JSON returned from trello.com is available as the _data attribute on all Trello objects:

In [7]: card._data
Out[7]:
{u'badges': {u'attachments': 0,
             u'checkItems': 0,
             u'checkItemsChecked': 0,
             u'comments': 1,
             u'description': True,
             u'due': None,
             u'fogbugz': u'',
             u'votes': 0},
 u'checkItemStates': [],
 u'closed': True,
 u'desc': u'And call it Trollop.',
 u'id': u'4f2e454cefab2bbd4ea71b02',
 u'idBoard': u'4e8df268f14f2517a7a342fa',
 u'idList': u'4f17cb04d5c817032301c179',
 u'idMembers': [],
 u'idShort': 130,
 u'labels': [],
 u'name': u'Build a Python Trello Library',
 u'url': u'https://trello.com/card/build-a-python-trello-library/4e8df268f14f2517a7a342fa/130'}

Trello objects have smart fields that automatically look up related objects:

In [9]: lst = card.list

In [10]: lst
Out[10]: <List: Icebox>

In [11]: lst.name
Out[11]: u'Icebox'

In [12]: lst._id
Out[12]: u'4f17cb04d5c817032301c179'

In [13]: len(lst.cards)
Out[13]: 20

In [14]: lst.cards[-1].name
Out[14]: u'Build a Python Trello Library'

Help Wanted

Coverage for creating/updating objects is still really thin. If you’d like to pitch in to finish covering the whole API, please send a pull request with your changes.

License

Trollop is licensed under the MIT License.

Metadata

Release files for trollop 0.0.17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trollop 0.0.17
File Size Uploaded
trollop-0.0.17.tar.gz 8.9 kB Details

Release files / trollop-0.0.17.tar.gz

Download URL trollop-0.0.17.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d3a347b79d1510565d3ec80c1706ed745c15e0799d353a4ed4a138f59f637869
BLAKE2b-256 checksum
How to use checksums
86efd030452d31a2185913786fadb9e30da5c13c916f7c26af0b1302e1fb976f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.0.17 This release

1 release file

0.0.16

1 release file

0.0.15

1 release file

0.0.14

1 release file

0.0.13

1 release file

0.0.12

1 release file

0.0.11

1 release file

0.0.10

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page