import requests
import json


def get_cards_total(board_id, app_key, user_token):
    """Fetches and returns the number of total cards within the Trello board"""

    # Constructing GET request to get all cards
    url = "https://api.trello.com/1/boards/%s/cards?key=%s&token=%s" % (board_id, app_key, user_token)

    response = requests.request("GET", url)
    resp = json.loads(response.text)

    return len(resp)