3
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

TrelloAPIをpythonで使う

Posted at

TrelloAPIをpythonで使う機会があったので、まとめておきます。

準備

.py
from trello import TrelloClient
import requests

key = '***********'
token = '***********'
trello = TrelloClient(key, token)

##ボード(名前、ID、URL)を取得

.py
boards=trello.list_boards()
for board in boards:
    print(board.name)
    print(board.id)
    print(board.url)
    print("---------------")

特定のボードの情報を取得

.py
#知りたいボードのIDを以下に代入
BOARD_ID="***********"

board=trello.get_board(BOARD_ID)
#リスト一覧取得
lists = board.all_lists()
#リスト名、リストID
for list_ in lists:
    print(list_.name)
    print(list_.id)

#カード一覧取得
cards=board.get_cards()
#カード名、説明、ID、URL
for card in cards:
    print(card.name)
    print(card.desc)
    print(card.id)
    print(card.url)
    print("------------------")

カードを特定のリストに追加

.py
BOARD_ID="***********"
LIST_ID="***********"

board = client.get_board(BOARD_ID)
target_list = board.get_list(LIST_ID)
#カード追加(カード名,説明)
created_card = target_list.add_card("card_name","card_desc")

説明、コメントを追加

.py
CARD_ID="***********"
#カードを選択
card=trello.get_card(CARD_ID)
#説明を追加
card.set_description("~~~~~~~~")
#コメントを追加
card.comment("~~~~~~~~")

カードにファイルを添付

.py
CARD_ID="***********"
#カードを選択
card=trello.get_card(CARD_ID)
file_path= "***********"
file =  open(file_path, 'rb')
card.attach(name="~~~~~~~~",file=file)

参考

py-trello

Simple python script to upload a file to Trello.

Python + py-trelloで、Trello APIを使ってみた

【Python】特定のハッシュタグが付いたツイートを自動的にTrelloのカードに追加

PythonでTrelloのタスクを取得する

3
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?