How to use the mintapi.api.Mint function in mintapi

To help you get started, we’ve selected a few mintapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mrooney / mintapi / mintapi / api.py View on Github external
keyring.set_password('mintapi', email, password)

    if options.accounts_ext:
        options.accounts = True

    if not any([options.accounts, options.budgets, options.transactions,
                options.extended_transactions, options.net_worth, options.credit_score,
                options.credit_report]):
        options.accounts = True

    if options.session_path == 'None':
        session_path = None
    else:
        session_path = options.session_path

    mint = Mint.create(email, password,
                       mfa_method=options.mfa_method,
                       session_path=session_path,
                       headless=options.headless,
                       imap_account=options.imap_account,
                       imap_password=options.imap_password,
                       imap_server=options.imap_server,
                       imap_folder=options.imap_folder,
                       wait_for_sync=not options.no_wait_for_sync,
                       wait_for_sync_timeout=options.wait_for_sync_timeout
                       )
    atexit.register(mint.close)  # Ensure everything is torn down.

    if options.imap_test:
        mfa_code = get_email_code(options.imap_account, options.imap_password, options.imap_server, imap_folder=options.imap_folder, debug=1, delete=0)
        print("MFA CODE:", mfa_code)
        sys.exit()
github jprouty / mint-amazon-tagger / mintamazontagger / mintclient.py View on Github external
if not email:
            email = input('Mint email: ')

        if not password:
            password = getpass.getpass('Mint password: ')

        if not email or not password:
            logger.error('Missing Mint email or password.')
            exit(1)

        logger.info('Logging into Mint')
        logger.info('You may be asked for an auth code at the command line! '
                    'Be sure to press ENTER after typing the 6 digit code.')

        mint_client = Mint.create(email, password,
                                  mfa_method=self.mfa_method,
                                  session_path=self.session_path,
                                  headless=self.headless,
                                  wait_for_sync=self.wait_for_sync)

        def close_mint_client():
            if mint_client:
                mint_client.close()

        atexit.register(close_mint_client)

        self.mintapi = mint_client
        return mint_client
github jprouty / mint-amazon-tagger / tagger.py View on Github external
if not email:
        email = input('Mint email: ')

    if not password:
        password = keyring.get_password(KEYRING_SERVICE_NAME, email)

    if not password:
        password = getpass.getpass('Mint password: ')

    if not email or not password:
        logger.error('Missing Mint email or password.')
        exit(1)

    asyncSpin = AsyncProgress(Spinner('Logging into Mint '))

    mint_client = Mint.create(email, password)

    # On success, save off password to keyring.
    keyring.set_password(KEYRING_SERVICE_NAME, email, password)

    asyncSpin.finish()

    return mint_client
github jprouty / mint-amazon-tagger / mintamazontagger / mintclient.py View on Github external
if not email:
            email = input('Mint email: ')

        if not password:
            password = getpass.getpass('Mint password: ')

        if not email or not password:
            logger.error('Missing Mint email or password.')
            exit(1)

        logger.info('Logging into Mint')
        logger.info('You may be asked for an auth code at the command line! '
                    'Be sure to press ENTER after typing the 6 digit code.')

        mint_client = Mint.create(email, password,
                                  mfa_method=self.mfa_method,
                                  session_path=self.session_path,
                                  headless=self.headless)
# Just kidding, wait_for_sync is not yet released :( oh noes.
#                                  wait_for_sync=self.wait_for_sync)

        def close_mint_client():
            if mint_client:
                mint_client.close()

        atexit.register(close_mint_client)

        self.mintapi = mint_client
        return mint_client
github mrooney / mintapi / mintapi / api.py View on Github external
# I can't find any way to retrieve this information other than by
        # doing this stupid one-call-per-account to listTransactions.xevent
        # and parsing the HTML snippet :(
        for account in accounts:
            headers = dict(JSON_HEADER)
            headers['Referer'] = '{}/transaction.event?accountId={}'.format(
                MINT_ROOT_URL, account['id'])

            list_txn_url = '{}/listTransaction.xevent'.format(MINT_ROOT_URL)
            params = {
                'accountId': str(account['id']),
                'queryNew': '',
                'offset': 0,
                'comparableType': 8,
                'acctChanged': 'T',
                'rnd': Mint.get_rnd(),
            }

            response = json.loads(self.get(
                list_txn_url, params=params, headers=headers).text)
            xml = '<div>' + response['accountHeader'] + '</div>'
            xml = xml.replace('–', '-')
            xml = xmltodict.parse(xml)

            account['availableMoney'] = None
            account['totalFees'] = None
            account['totalCredit'] = None
            account['nextPaymentAmount'] = None
            account['nextPaymentDate'] = None

            xml = xml['div']['div'][1]['table']
            if 'tbody' not in xml:
github mrooney / mintapi / mintapi / api.py View on Github external
def get_net_worth(email, password):
    mint = Mint.create(email, password)
    account_data = mint.get_accounts()
    return mint.get_net_worth(account_data)
github mrooney / mintapi / mintapi / api.py View on Github external
start_date = None
        all_txns = []
        offset = 0
        # Mint only returns some of the transactions at once.  To get all of
        # them, we have to keep asking for more until we reach the end.
        while 1:
            # Specifying accountId=0 causes Mint to return investment
            # transactions as well.  Otherwise they are skipped by
            # default.
            url = (
                MINT_ROOT_URL +
                '/getJsonData.xevent?' +
                'queryNew=&amp;offset={offset}&amp;comparableType=8&amp;' +
                'rnd={rnd}&amp;{query_options}').format(
                offset=offset,
                rnd=Mint.get_rnd(),
                query_options=(
                    'accountId=' + str(id) + '&amp;task=transactions' if include_investment
                    else 'accountId=' + str(id) + '&amp;task=transactions,txnfilters&amp;filterType=cash' if id &gt; 0
                    else 'task=transactions,txnfilters&amp;filterType=cash'))
            result = self.request_and_check(
                url, headers=JSON_HEADER,
                expected_content_type='text/json|application/json')
            data = json.loads(result.text)
            txns = data['set'][0].get('data', [])
            if not txns:
                break
            if start_date:
                last_dt = json_date_to_datetime(txns[-1]['odate'])
                if last_dt &lt; start_date:
                    keep_txns = [
                        t for t in txns
github mrooney / mintapi / mintapi / api.py View on Github external
def get_net_worth(email, password):
    mint = Mint.create(email, password)
    account_data = mint.get_accounts()
    return mint.get_net_worth(account_data)
github mrooney / mintapi / mintapi / api.py View on Github external
def create(cls, email, password, **opts):
        return Mint(email, password, **opts)