Last active
January 5, 2021 19:36
-
-
Save csmaniottojr/6e679143d16007490b0617f35d678f9c to your computer and use it in GitHub Desktop.
Order cards from a Trello list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import operator | |
params = {"token": "", "key": ""} | |
id_list = "" | |
cards = requests.get( | |
"https://api.trello.com/1/lists/{}/cards".format(id_list), params=params | |
).json() | |
order_by_asc = True | |
# sort by due date in ascending order | |
cards_sorted = sorted(cards, key=operator.itemgetter("due"), reverse=not order_by_asc) | |
pos = "bottom" if order_by_asc else "top" | |
for card in cards_sorted: | |
requests.put( | |
"https://api.trello.com/1/cards/{}".format(card["id"]), | |
params=params, | |
data={"pos": pos}, | |
).json() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment