personalcapital
personalcapital copied to clipboard
PersonalCapital's API documentation
Is there any doco out there for the REST API that this library communicates with? perhaps a swagger of something of the like?
Is this code still work for personal capitals API structure. I'm getting.....
KeyError Traceback (most recent call last)
KeyError: 'spData'
@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.
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?
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.
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)
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.