Search code examples
pythontrello

Check if board, list, or card exists in trello


Is there a way to check if a board, list, or card exists in Trello? Would like to create a python script that will display the list of the mentioned components if the name already exists.

I checked the API it seems there is no query function.

Hoping for your inputs. Thanks in advance.


Solution

  • Got it now. I was able to use the search API from trello. https://developer.atlassian.com/cloud/trello/rest/api-group-search/#api-search-get

    Sharing the code:

    def search_board(board_name):
        url = "https://api.trello.com/1/search"
        querystring = {"query": board_name, "key": key, "token": token}
        response = requests.request("GET", url, params=querystring)
        print(response)
        board_id = ""
        print(response.json())
        if response.json()["boards"]:
            board_id = response.json()["boards"][0]["id"]
            print(board_id)
        else:
           return board_id