Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Turn Trello cards into Habitica tasks; remove cards
#!/usr/bin/python
# requires trello, requests, available through pip
from trello import TrelloApi
import json, os, requests, subprocess
HABITICA_USER = os.getenv('HAB_API_USER', '')
HABITICA_KEY = os.getenv('HAB_API_TOKEN', '')
TRELLO_KEY = os.getenv('TRELLO_API_KEY', '')
TRELLO_TOKEN = os.getenv('TRELLO_API_TOKEN', '')
TRELLO_BOARD = os.getenv('TRELLO_API_BOARD', '')
headers = {"x-api-key":HABITICA_KEY,"x-api-user":HABITICA_USER,"Content-Type":"application/json"}
trello = TrelloApi(TRELLO_KEY, token=TRELLO_TOKEN)
results = trello.lists.get_card(TRELLO_BOARD)
for card in results:
task = {
"type" : "todo",
"text" : card['name'],
"notes" : card['id']
}
req = requests.post("https://habitica.com/api/v3/tasks/user", headers=headers, data=json.dumps(task))
trello.cards.delete(card['id'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.