Use Trello API with python

I had a chance to use Trello API with python, so I will summarize it.

Preparation

from trello import TrelloClient
import requests

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

Get board (name, ID, URL)

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

Get information about a specific board

#Substitute the ID of the board you want to know below
BOARD_ID="***********"

board=trello.get_board(BOARD_ID)
#Get list list
lists = board.all_lists()
#List name, list ID
for list_ in lists:
    print(list_.name)
    print(list_.id)

#Get a list of cards
cards=board.get_cards()
#Card name, description, ID, URL
for card in cards:
    print(card.name)
    print(card.desc)
    print(card.id)
    print(card.url)
    print("------------------")

Add card to a specific list

BOARD_ID="***********"
LIST_ID="***********"

board = client.get_board(BOARD_ID)
target_list = board.get_list(LIST_ID)
#Add card (card name,Description)
created_card = target_list.add_card("card_name","card_desc")

Add description and comment

CARD_ID="***********"
#Select a card
card=trello.get_card(CARD_ID)
#Add a description
card.set_description("~~~~~~~~")
#Add comment
card.comment("~~~~~~~~")

Attach file to card

CARD_ID="***********"
#Select a card
card=trello.get_card(CARD_ID)
file_path= "***********"
file =  open(file_path, 'rb')
card.attach(name="~~~~~~~~",file=file)

reference

py-trello

Simple python script to upload a file to Trello.

I tried using the Trello API with Python + py-trello

[Python] Automatically add tweets with specific hashtags to Trello's card

Get Trello tasks in Python

Recommended Posts

Use Trello API with python
Use Twitter API with Python
Use subsonic API with python3
[Python] Use JSON with Python
Use mecab with Python3
Use DynamoDB with Python
Use Python 3.8 with Anaconda
Use python with docker
Use TUN / TAP with Python
Web API with Python + Falcon
Play RocketChat with API / Python
Call the API with python3.
Use e-Stat API from Python
Python: How to use async with
Use PointGrey camera with Python (PyCapture2)
Use vl53l0x with Raspberry Pi (python)
Create Awaitable with Python / C API
Get reviews with python googlemap api
Run Rotrics DexArm with python API
[Python] Use Basic/Digest authentication with Flask
Quine Post with Qiita API (Python)
Use NAIF SPICE TOOLKIT with Python
Use rospy with virtualenv in Python3
Hit the Etherpad-lite API with Python
[python] Read information with Redmine API
Use kabu StationĀ® API from Python
Use Python in pyenv with NeoVim
How to use OpenPose's Python API
Use the Flickr API from Python
How to use FTP with Python
Use Windows 10 speech synthesis with Python
Use OpenCV with Python 3 in Window
Use PostgreSQL with Lambda (Python + psycopg2)
[Python] How to use Typetalk API
Use Google Analytics API from Python
Easy to use Nifty Cloud API with botocore and python
Collecting information from Twitter with Python (Twitter API)
FizzBuzz with Python3
Scraping with Python
Automatically create Python API documentation with Sphinx
Statistics with python
Use smbus with python3 under pyenv environment
Use DeepL with python (for dissertation translation)
Simple Slack API client made with Python
Scraping with Python
Retrieving food data with Amazon API (Python)
Python with Go
[September 2020 version] Explains the procedure to use Gmail API with Python
Use Amazon Simple Notification Service with Python
Twilio with Python
Integrate with Python
[Python] Use string data with scikit-learn SVM
Sample to use after OAuth authentication of BOX API with Python
Play with 2016-Python
[Introduction to Python] Let's use foreach with Python
Use PIL and Pillow with Cygwin Python
AES256 with python
Use cryptography library cryptography with Docker Python image
Tested with Python
Use Google Cloud Vision API from Python
python starts with ()