Python script and Shortcut to view the amount invested

Hi all

Just made a small python script that lets you check the amount that has been invested in Monzo so far.

I’ve seen lots of people saying the site is behind, so if you run this it will quickly tell you how much has been invested.

To run, you’ll need to have Beautiful Soup and URLlib.

I also made a Shortcut that runs in the Shortcuts app: https://www.icloud.com/shortcuts/e6e5f128ede04660929792e1c70b7515

Hope you find it useful!

Thanks

9 Likes

Just curious… the endpoint returns JSON for me… how does this BeautifulSoup thing even parse it?

I’m pretty new to Python and it was the only way I knew how to scrape a site. I tried to use Requests but couldn’t figure it out.

Thanks! :slightly_smiling_face:

1 Like

Also I don’t really know what category this should be in, so apologies if it is in the wrong one!

Or an alternative in JavaScript. Just press F12 in Chrome to open up Developer Tools, go to the Console and paste this in and then press Return!

(await (await fetch("https://api.monzo.com/crowdfunding-investment/total")).json()).invested_amount

Or the fatter (and friendly) version of the above:

let url = "https://api.monzo.com/crowdfunding-investment/total"

let response = await fetch(url)

let data = await response.json()

data.invested_amount
1 Like

I have no experience in JavaScript. Wanted to try using the API in Python as I haven’t every done something like it before. :slight_smile:

1 Like

Given that the endpoint provides JSON, something like this might be easier:

data = requests.get("https://api.monzo.com/crowdfunding-investment/total").json()

where data is a dictionary with the same keys/values as the JSON.

3 Likes

I’ll try it out now - thanks!

1 Like

Wow, thats a lot neater! I’m going to implement it and update the script.

1 Like

Can’t seem to get it to work. Having issues splitting it for the investment variable.


Also just made a Shortcut! Shortcuts

Ultimately, you could tidy up some of the casting/string manipulation, but keeping it close to your original version:

1 Like

Thank you! Looks a lot cleaner. Thanks for your help :slightly_smiling_face:

Is it ok if I update the repo, or do you want to make a pull request?

Thanks!

3 Likes

I’ve no problem with you updating your repo with it.

2 Likes

Neat! I was going to make something like this but hitting refresh was lower effort :sweat_smile:

1 Like

Glad you like it!

I made it as I hadn’t used Python in a while and wanted to try out using an API. Was a fun little project!

4 Likes

Cool! I am trying to fetch information from my account using python and requests, but I am getting errors when attempt to authenticate. Have you tried it before? Could you help me please? Cheers!

Hello, I haven’t used that part of the api so wouldn’t know. Sorry!

I tried Tommy5dollar’s recipe and got this as an answer… 199999955400

I guess those are Venezuelan Bolivars or somesuch? :grinning:

Divide it by 10,000 and you get £19,999,995.54, just a tad below the £20m because +1 share would put it over £20m :wink:

:+1: