personalcapital icon indicating copy to clipboard operation
personalcapital copied to clipboard

PersonalCapital's API documentation

Open swvajanyatek opened this issue 5 years ago • 6 comments

Is there any doco out there for the REST API that this library communicates with? perhaps a swagger of something of the like?

swvajanyatek avatar Jul 19 '19 19:07 swvajanyatek

Is this code still work for personal capitals API structure. I'm getting.....

KeyError Traceback (most recent call last) in ----> 1 accounts = accounts_response.json()['spData']

KeyError: 'spData'

markcav avatar Sep 03 '19 06:09 markcav

@swvajanyatek, I don't believe that there is any documentation. The author of the library can correct me if I'm wrong, but based on my personal investigation, I believe this library is built off of some sleuthing of the REST interactions that the site is using.

ebrooks42 avatar Jan 10 '20 04:01 ebrooks42

any updates on this. I'm able to get connected to my account but only able to access superficial information like net worth and a few other numbers. I would like to get time series data of transactions. Is this possible?

CRG180 avatar Mar 08 '20 22:03 CRG180

any updates on this. I'm able to get connected to my account but only able to access superficial information like net worth and a few other numbers. I would like to get time series data of transactions. Is this possible?

I've

Is this code still work for personal capitals API structure. I'm getting.....

KeyError Traceback (most recent call last) in ----> 1 accounts = accounts_response.json()['spData']

KeyError: 'spData'

@markcav, you should examine the structure yourself to see what's in there. For me, usually the KeyError: 'spData' indicates that there was an error, and you need to look at the errors in the spHeader.

Try this:

def process_response(resp):
    try:
        return resp.json()['spData']
    except KeyError:
        errors = resp.json()['spHeader'].get('errors', [])
        for error in errors:
            logging.error("Error: %s", error)
    except ValueError:
        resp.raise_for_status()

r = pc.fetch('/newaccount/getAccounts')
data = process_response(r)

This function should get your data, or expose any errors that occur.

philipsd6 avatar Mar 17 '20 19:03 philipsd6

any updates on this. I'm able to get connected to my account but only able to access superficial information like net worth and a few other numbers. I would like to get time series data of transactions. Is this possible?

It's definitely possible -- I've done it myself. Use my process_response() function above (which maybe we might incorporate into the codebase!) and try this:

r = pc.fetch('/newaccount/getAccounts')
accounts = process_response(r)
account_ids = [a['userAccountId'] for a in accounts['accounts']]
r = pc.fetch('/transaction/getUserTransactions', {
    'userAccountIds': str(account_ids),
    'sort_cols': 'transactionTime',
    'sort_rev': 'true',
    'page': '0',
    'rows_per_page': '1000',
    'startDate': '2020-01-01',
    'endDate': '2020-01-31',
    'component': 'DATAGRID'
})
transactions = process_response(r)

philipsd6 avatar Mar 17 '20 20:03 philipsd6

I added a page to the wiki: https://github.com/haochi/personalcapital/wiki/List-of-possible-API-routes

I scraped the site, pulled the routes, and json-formatted them. I haven't tested any of them and there are no descriptions, but the titles and the routes themselves are pretty informative.

TheBrainChain avatar Aug 06 '22 15:08 TheBrainChain