Import data from Trello using API

Hi
I’m dealing with a CSV of Trello that is too big for excel.

Trying to instead use the API to achieve this. Is anyone familar with MondayClient, the documentation I found is not sufficient.

All I really need to do is find how to create a group, and then an item with in that group with a description and a checklist. So not too hard but having difficulties with the premade solutions provided by Monday in that respect.

Thanks very much

1 Like

Hey @hmbl4, welcome to the community!

While this isn’t an official Python library, it’s awesome that one of our users created it! In the meantime, here’s some code you can use to start doing what you’re trying to do.

Here is a snippet that I’ve found super helpful for sending generic queries over to our API:

# Function to make an API query using the string passed in "query"
def makeAPIQuery(query, variables, apiKey):
	headers = {"Authorization" : apiKey} # set headers
	URL = "https://api.monday.com/v2"
	data = {"query" : query, "variables" : variables}
	r = requests.post(url=URL, json=data, headers=headers) # make request
	if r.status_code == 401:
		print('Status: ', r.status_code)
		raise PermissionError("Check your API key!")
	if r.status_code != 200:
		print('Status:', r.status_code)
		raise ValueError("Check your query contents!")
	if ("errors" in r.json().keys()):
		print(r.json())
		raise SyntaxError("Check your query syntax!")
	else: 
		results = r.json()
		return results

As for creating a group, you’ll want to use the “create_group” mutation:

mutation {
  create_group (board_id: 20178755, group_name: "new group") {
    id
  }
}

And this mutation for creating an item:

mutation {
  create_item (board_id: 20178755, group_id: "today", item_name: "Hello world") {
    id
  }
}

Finally, you can use the create_update mutation to add an update. I’d suggest putting the description and checklist inside an update:

mutation {
  create_update (item_id: 20178755, body: "This update will be added to the item") {
    id
  }
}

I hope that helps! :slight_smile: