trello package

Submodules

trello.attachments module

class trello.attachments.Attachments(id, bytes, date, edge_color, idMember, is_upload, mime_type, name, previews, url)[source]

Bases: trello.base.TrelloBase

https://developers.trello.com/advanced-reference/card#get-1-cards-card-id-or-shortlink-attachments

static from_json(json_obj)[source]
class trello.attachments.AttachmentsPreview(bytes, url, width, height, is_scaled)[source]

Bases: object

static from_json(json_obj)[source]

trello.base module

class trello.base.TrelloBase[source]

Bases: object

trello.board module

class trello.board.Board(client=None, board_id=None, organization=None, name='')[source]

Bases: trello.base.TrelloBase

Class representing a Trello board. Board attributes are stored as normal Python attributes; access to all sub-objects, however, is always an API call (Lists, Cards).

add_label(name, color)[source]

Add a label to this board

Name:name of the label
Color:the color, either green, yellow, orange red, purple, blue, sky, lime, pink, or black
Returns:the label
Return type:Label
add_list(name, pos=None)[source]

Add a list to this board

Name:name for the list
Pos:position of the list: “bottom”, “top” or a positive number
Returns:the list
Return type:List
add_member(member, member_type='normal')[source]
admin_members()[source]

Returns all admin members on this board

Return type:list of Member
all_cards()[source]

Returns all cards on this board

Return type:list of Card
all_lists()[source]

Returns all lists on this board

Return type:list of List
all_members()[source]

Returns all members on this board

Return type:list of Member
close()[source]
closed_cards()[source]

Returns all closed cards on this board

Return type:list of Card
closed_lists()[source]

Returns all closed lists on this board

Return type:list of List
fetch()[source]

Fetch all attributes for this board

fetch_actions(action_filter, action_limit=50, before=None, since=None)[source]

Returns all actions that conform to the given filters.

Action_filter:str of possible actions separated by comma ie. ‘createCard,updateCard’
Action_limit:int of max items returned
Before:datetime obj
Since:datetime obj

More info on action filter values: https://developers.trello.com/advanced-reference/board#get-1-boards-board-id-actions

Return type:json list of past actions
classmethod from_json(trello_client=None, organization=None, json_obj=None)[source]

Deserialize the board json object to a Board object

Trello_client:the trello client
Json_obj:the board json object

Alternative contrustraction:

Deserialize the board json object to a board object

Organization:the organization object that the board belongs to
Json_obj:the json board object
get_cards(filters=None, card_filter='')[source]
Filters:dict containing query parameters. Eg. {‘fields’: ‘all’}
Card_filter:filters on card status (‘open’, ‘closed’, ‘all’)

More info on card queries: https://trello.com/docs/api/board/index.html#get-1-boards-board-id-cards

Return type:list of Card
get_checklists(cards='all')[source]

Get checklists

Return type:list of Checklist
get_labels(fields='all', limit=50)[source]

Get label

Return type:list of Label
get_last_activity()[source]

Return the date of the last action done on the board.

Return type:datetime.datetime
get_list(list_id)[source]

Get list

Return type:List
get_lists(list_filter)[source]

Get lists from filter

Return type:list of List
get_members(filters=None)[source]

Get members with filter

Filters:dict containing query parameters. Eg. {‘fields’: ‘all’, ‘filter’: ‘admins’}

More info on possible filters: https://developers.trello.com/advanced-reference/board#get-1-boards-board-id-members

Return type:list of Member
list_lists(list_filter='all')[source]

Get lists from filter

Return type:list of List
normal_members()[source]

Returns all normal members on this board

Return type:list of Member
open()[source]
open_cards()[source]

Returns all open cards on this board

Return type:list of Card
open_lists()[source]

Returns all open lists on this board

Return type:list of List
owner_members()[source]

Returns all owner members on this board

Return type:list of Member
remove_member(member)[source]
save()[source]
set_description(desc)[source]
set_name(name)[source]

trello.card module

class trello.card.Card(parent, card_id, name='')[source]

Bases: trello.base.TrelloBase

Class representing a Trello card. Card attributes are stored on the object

https://developers.trello.com/advanced-reference/card

add_checklist(title, items, itemstates=None)[source]

Add a checklist to this card

Title:title of the checklist
Items:a list of the item names
Itemstates:a list of the state (True/False) of each item
Returns:the checklist
add_label(label)[source]
add_member(member)[source]
assign(member_id)[source]
attach(name=None, mimeType=None, file=None, url=None)[source]

Add an attachment to the card. The attachment can be either a file or a url. Setting the name and/or mime type is optional. :param name: The name of the attachment :param mimeType: mime type for the attachement :param file: a file-like, binary object that supports read() :param url: a URL pointing to the resource to be attached

attachments

Lazily loads and returns the attachments

attriExp(multiple)[source]

Provides the option to explore what comes from trello :multiple is one of the attributes of GET /1/cards/[card id or shortlink]/actions

board_id
card_created_date

Will return the creation date of the card.

NOTE: This will return the date the card was created, even if it was created on another board. The created_date() above actually just returns the first activity and has the issue described in the warning.

The first 8 characters of the card id is a hexadecimal number. Converted to a decimal from hexadecimal, the timestamp is an Unix timestamp (the number of seconds that have elapsed since January 1, 1970 midnight UTC. See http://help.trello.com/article/759-getting-the-time-a-card-or-board-was-created

change_board(board_id, list_id=None)[source]
change_list(list_id)[source]
change_pos(position)[source]
checklists

Lazily loads and returns the checklists

comment(comment_text)[source]

Add a comment to a card.

Comment_text:str
comments

Lazily loads and returns the comments

created_date

Will return the creation date of the card.

WARNING: if the card was create via convertion of a checklist item
it fails. attriExp(‘convertToCardFromCheckItem’) allows to test for the condition.
date_last_activity
delete()[source]
delete_comment(comment)[source]
description
due_date
fetch(eager=True)[source]

Fetch all attributes for this card

Parameters:eager – If eager, comments, checklists and attachments will be fetched immediately, otherwise on demand
fetch_actions(action_filter='createCard', since=None, before=None)[source]

Fetch actions for this card can give more argv to action_filter, split for ‘,’ json_obj is list

fetch_attachments(force=False)[source]
fetch_checklists()[source]
fetch_comments(force=False, limit=None)[source]
fetch_plugin_data()[source]
classmethod from_json(parent, json_obj)[source]

Deserialize the card json object to a Card object

Parent:the list object that the card belongs to
Json_obj:json object
Return type:Card
get_attachments()[source]
get_comments()[source]

Alias for fetch_comments for backward compatibility. Always contact server

get_list()[source]
get_stats_by_list(lists, list_cmp=None, done_list=None, time_unit='seconds', card_movements_filter=None)[source]

Gets several stats about the card by each list of the board: - time: The time that the card has been in each column in seconds (minutes or hours). - forward_moves: How many times this card has been the source of a forward movement. - backward_moves: How many times this card has been the source of a backward movement.

Returns a dict where the key is list id and value is a dict with keys time, forward_moves and backward_moves.

Parameters:
  • lists – list of board lists.
  • list_cmp – function that compares two lists a,b given id_a, id_b. If b is in a forward position returns 1 else -1.
  • time_unit – default to seconds. Allow specifying time in “minutes” or “hours”.
  • done_list – Column that implies that the task is done. If present, time measurement will be stopped if is current task list.
  • card_movements_filter – Pair of two dates (two strings in YYYY-MM-DD format) that will filter the movements of the card. Optional.
Returns:

dict of the form {list_id: {time:<time card was in that list>, forward_moves: <number>, backward_moves: <number> }}

idLabels
latestCardMove_date

Returns the date of the last card transition

listCardMove_date()[source]

Will return the history of transitions of a card from one list to another. The lower the index the more resent the historical item.

It returns a list of lists. The sublists are triplets of starting list, ending list and when the transition occurred.

list_id
list_labels
list_movements(list_cmp=None, filter_by_date_interval=None)[source]

Will return the history of transitions of a card from one list to another. The lower the index the more resent the historical item.

It returns a list of dicts in date and time descending order (the first movement is the earliest). Dicts are of the form source: <listobj> destination: <listobj> datetime: <datetimeobj>

Param:list_cmp Comparison function between lists. For list_cmp(a, b) returns -1 if list a is greater that list b. Returns 1 otherwise.
Param:filter_by_date_interval: pair of two dates (two strings in YYYY-MM-DD format) to filter card movements by date.
member_id
plugin_data

Lazily loads and returns the plugin data

remove_attachment(attachment_id)[source]

Remove attachment from card :param attachment_id: Attachment id :return: None

remove_due()[source]

Remove the due datetime of this card.

remove_due_complete()[source]

Remove due complete

Returns:None
remove_label(label)[source]
remove_member(member)[source]
set_closed(closed)[source]
set_description(description)[source]
set_due(due)[source]

Set the due time for the card

Due:a datetime object
set_due_complete()[source]

Set due complete

Returns:None
set_name(new_name)[source]

Update the name on the card to :new_name:

New_name:str
set_pos(pos)[source]

Update card position in list

Pos:‘top’, ‘bottom’ or int
short_id
short_url
subscribe()[source]
unassign(member_id)[source]
update_comment(comment_id, comment_text)[source]

Update a comment.

trello.checklist module

class trello.checklist.Checklist(client, checked, obj, trello_card=None)[source]

Bases: trello.base.TrelloBase

Class representing a Trello checklist.

add_checklist_item(name, checked=False)[source]

Add a checklist item to this checklist

Name:name of the checklist item
Checked:True if item state should be checked, False otherwise
Returns:the checklist item json object
clear()[source]

Clear checklist by removing all checklist items

delete()[source]

Removes this checklist

delete_checklist_item(name)[source]

Delete an item on this checklist

Name:name of the checklist item to delete
rename(new_name)[source]

Rename this checklist

New_name:new name of the checklist
rename_checklist_item(name, new_name)[source]

Rename the item on this checklist

Name:name of the checklist item
New_name:new name of item
set_checklist_item(name, checked)[source]

Set the state of an item on this checklist

Name:name of the checklist item
Checked:True if item state should be checked, False otherwise

trello.compat module

trello.compat.force_str(s, encoding='utf-8')[source]

Converts s to the str type, regardless of the Python version. This is useful for __repr__ return types, where a str (bytes) is expected in Python 2 and a str (unicode string) is expected in Python 3.

trello.exceptions module

exception trello.exceptions.ResourceUnavailable(msg, http_response)[source]

Bases: exceptions.Exception

Exception representing a failed request to a resource

exception trello.exceptions.TokenError[source]

Bases: exceptions.Exception

exception trello.exceptions.Unauthorized(msg, http_response)[source]

Bases: trello.exceptions.ResourceUnavailable

trello.label module

class trello.label.Label(client, label_id, name, color='')[source]

Bases: trello.base.TrelloBase

Class representing a Trello Label.

fetch()[source]

Fetch all attributes for this label

classmethod from_json(board, json_obj)[source]

Deserialize the label json object to a Label object

Board:the parent board the label is on
Json_obj:the label json object
classmethod from_json_list(board, json_objs)[source]

trello.member module

class trello.member.Member(client, member_id, full_name='')[source]

Bases: trello.base.TrelloBase

Class representing a Trello member.

fetch()[source]

Fetch all attributes for this member

fetch_cards()[source]

Fetches all the cards for this member

fetch_comments()[source]
fetch_notifications(filters=[])[source]

Fetches all the notifications for this member

classmethod from_json(trello_client, json_obj)[source]

Deserialize the organization json object to a member object

Trello_client:the trello client
Json_obj:the member json object

trello.organization module

class trello.organization.Organization(client, organization_id, name='')[source]

Bases: trello.base.TrelloBase

TIMEZONE = None

Class representing an organization

all_boards()[source]

Returns all boards on this organization

fetch()[source]

Fetch all attributes for this organization

classmethod from_json(trello_client, json_obj)[source]

Deserialize the board json object to a Organization object

Trello_client:the trello client
Json_obj:the board json object
get_board(field_name)[source]

Get board

Return type:list of Board
get_boards(list_filter)[source]

Get boards using filter

Return type:list of Board
get_members()[source]

trello.trelloclient module

class trello.trelloclient.TrelloClient(api_key, api_secret=None, token=None, token_secret=None)[source]

Bases: object

Base class for Trello API access

add_board(board_name, source_board=None, organization_id=None, permission_level='private')[source]

Create board :param board_name: Name of the board to create :param source_board: Optional Board to copy :param permission_level: Permission level, defaults to private :rtype: Board

create_hook(callback_url, id_model, desc=None, token=None)[source]

Creates a new webhook. Returns the WebHook object created.

There seems to be some sort of bug that makes you unable to create a hook using httplib2, so I’m using urllib2 for that instead.

fetch_json(uri_path, http_method='GET', headers=None, query_params=None, post_args=None, files=None)[source]

Fetch some JSON from Trello

get_board(board_id)[source]

Get board

Return type:Board
get_card(card_id)[source]

Get card

Return type:Card
get_label(label_id, board_id)[source]

Get Label

Requires the parent board id the label is on

Return type:Label
get_list(list_id)[source]

Get list

Return type:List
get_member(member_id)[source]

Get member

Return type:Member
get_organization(organization_id)[source]

Get organization

Return type:Organization
info_for_all_boards(actions)[source]

Use this if you want to retrieve info for all your boards in one swoop

list_boards(board_filter='all')[source]

Returns all boards for your Trello user

Returns:a list of Python objects representing the Trello boards.
Return type:list of Board
Each board has the following noteworthy attributes:
  • id: the board’s identifier
  • name: Name of the board
  • desc: Description of the board (optional - may be missing from the
    returned JSON)
  • closed: Boolean representing whether this board is closed or not
  • url: URL to the board
list_hooks(token=None)[source]

Returns a list of all hooks associated with a specific token. If you don’t pass in a token, it tries to use the token associated with the TrelloClient object (if it exists)

list_organizations()[source]

Returns all organizations for your Trello user

Returns:a list of Python objects representing the Trello organizations.
Return type:list of Organization
Each organization has the following noteworthy attributes:
  • id: the organization’s identifier
  • name: Name of the organization
  • desc: Description of the organization (optional - may be missing from the
    returned JSON)
  • closed: Boolean representing whether this organization is closed or not
  • url: URL to the organization
logout()[source]

Log out of Trello.

search(query, partial_match=False, models=[], board_ids=[], org_ids=[], card_ids=[])[source]

Search trello given a query string.

Parameters:
  • query (str) – A query string up to 16K characters
  • partial_match (bool) – True means that trello will look for content that starts with any of the words in your query.
  • models (list) – Comma-separated list of types of objects to search. This can be ‘actions’, ‘boards’, ‘cards’, ‘members’, or ‘organizations’. The default is ‘all’ models.
  • board_ids (list) – Comma-separated list of boards to limit search
  • org_ids – Comma-separated list of organizations to limit search
  • card_ids – Comma-separated list of cards to limit search
Returns:

All objects matching the search criterial. These can be Cards, Boards, Organizations, and Members. The attributes of the objects in the results are minimal; the user must call the fetch method on the resulting objects to get a full set of attributes populated.

Rtype list:

trello.trellolist module

class trello.trellolist.List(board, list_id, name='')[source]

Bases: trello.base.TrelloBase

Class representing a Trello list. List attributes are stored on the object, but access to sub-objects (Cards) require an API call

add_card(name, desc=None, labels=None, due='null', source=None, position=None, assign=None)[source]

Add a card to this list

Name:name for the card
Desc:the description of the card
Labels:a list of label IDs to be added
Due:due date for the card
Source:card ID from which to clone from
Position:position of the card in the list. Must be “top”, “bottom” or a positive number.
Returns:the card
archive_all_cards()[source]
cardsCnt()[source]
close()[source]
fetch()[source]

Fetch all attributes for this list

fetch_actions(action_filter)[source]

Fetch actions for this list can give more argv to action_filter, split for ‘,’ json_obj is list

classmethod from_json(board, json_obj)[source]

Deserialize the list json object to a List object

Board:the board object that the list belongs to
Json_obj:the json list object
list_cards(card_filter='open', actions=None)[source]

Lists all cards in this list

move(position)[source]
move_all_cards(destination_list)[source]

Move all cards of this list to another list. The list can be in the same board (or not).

open()[source]
set_name(name)[source]
set_pos(position)[source]

trello.util module

trello.util.create_oauth_token(expiration=None, scope=None, key=None, secret=None, name=None, output=True)[source]

Script to obtain an OAuth token from Trello.

Must have TRELLO_API_KEY and TRELLO_API_SECRET set in your environment To set the token’s expiration, set TRELLO_EXPIRATION as a string in your environment settings (eg. ‘never’), otherwise it will default to 30 days.

More info on token scope here:
https://trello.com/docs/gettingstarted/#getting-a-token-from-a-user

trello.webhook module

class trello.webhook.WebHook(client, token, hook_id=None, desc=None, id_model=None, callback_url=None, active=False)[source]

Bases: object

Class representing a Trello webhook.

delete()[source]

Removes this webhook from Trello

Module contents