API for fetching historical Vanguard NAV prices?

690 views
Skip to first unread message

Aaron Stacy

unread,
Oct 9, 2021, 11:53:42 AM10/9/21
to ledge...@googlegroups.com
I've got a script that fetches prices for Vanguard frunds from one of the APIs I found their website was making XHR's to. It looks something like (tho I also needed the "Referer: https://vanguard.com" header:


This has worked for most of a year, up til last month, not only for ETFs, but also Vanguard funds like their target retirement funds, and even the target retirement trust fund my company uses for the 401k, but now I'm getting 404s.

I've found this will give me JSON of today's price (but not historical):


And this will give me HTML of historical prices, but not for the Target Retirement 2050 Trust fund my company uses for their 401k:


Does anyone know of APIs to fetch NAV prices for these funds by date?

Aaron Stacy

unread,
Oct 9, 2021, 11:55:10 AM10/9/21
to ledge...@googlegroups.com
...and I can answer my own question, but I'll post it here in case it saves anyone else some time:

The JSON API that now works came from inspecting this page, and searching through the XHRs for the NAV price listed. This came up (no headers seem to be needed):

    https://eds.ecs.gisp.c1.vanguard.com/eds-eip-distributions-service/price/daily-nav-history/7743.json?start-date=2021-10-08&end-date=2021-10-09

Where "7743" is the FIID (fund ID? IDK), and while I don't remember where I originally got 7743, I think it was in the malformed OFX export XML from logging into my Vanguard portal.

Aaron Stacy

unread,
Oct 9, 2021, 11:56:00 AM10/9/21
to ledge...@googlegroups.com
And of course feel free to share if anyone has ideas for getting stuff like this from a proper API 🙂

Chris Berkhout

unread,
Oct 10, 2021, 9:14:53 AM10/10/21
to ledge...@googlegroups.com
The data comes in HTML but this looks like a pretty clean and self-explanatory interface for Vanguard US:

--

---
You received this message because you are subscribed to the Google Groups "Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ledger-cli+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ledger-cli/CACjABk%3DYC29kxrLsM4n3qm%3DP-oZ0RSZxBEsrWLN4tEvGycpQkg%40mail.gmail.com.

Viraj Alankar

unread,
Aug 31, 2022, 8:54:33 AM8/31/22
to Ledger
Not sure if my message was posted, sorry if this is a dupe.

On Sunday, October 10, 2021 at 3:14:53 PM UTC+2 chrisb...@gmail.com wrote:
The data comes in HTML but this looks like a pretty clean and self-explanatory interface for Vanguard US:

Unfortunately this doesn't work for some funds, like #  7741 which is "Vanguard Target Retirement 2040 Trust".


On Sat, 9 Oct 2021 at 17:55, Aaron Stacy <aaron....@gmail.com> wrote:
And of course feel free to share if anyone has ideas for getting stuff like this from a proper API 🙂

On Sat, Oct 9, 2021 at 10:54 AM Aaron Stacy <aaron....@gmail.com> wrote:
...and I can answer my own question, but I'll post it here in case it saves anyone else some time:

The JSON API that now works came from inspecting this page, and searching through the XHRs for the NAV price listed. This came up (no headers seem to be needed):

    https://eds.ecs.gisp.c1.vanguard.com/eds-eip-distributions-service/price/daily-nav-history/7743.json?start-date=2021-10-08&end-date=2021-10-09

Where "7743" is the FIID (fund ID? IDK), and while I don't remember where I originally got 7743, I think it was in the malformed OFX export XML from logging into my Vanguard portal.

This seems to work pretty good, but for some reason it has stopped responding from some IPs. It gives:


< HTTP/1.1 302 Moved Temporarily
< Transfer-Encoding: chunked
< Connection: keep-alive
< Date: Wed, 31 Aug 2022 12:42:57 GMT
< Cache-Control: no-cache
< Expires: 0
< Location: http://www.vanguard.com/notfound.htm
< Pragma: no-cache
< X-Cache: Miss from cloudfront
< Via: 1.1 2a46367687c8f1815bbea20c92c7d64c.cloudfront.net (CloudFront)
< X-Amz-Cf-Pop: AMS1-P2
< X-Amz-Cf-Id: i5Rwg5vzh336Pk4Zfc9G9l4sX85iKwa75HAvd0Wpr7iU1HhF1Uq1JA==
<
* Curl_http_done: called premature == 0
* Connection #0 to host eds.ecs.gisp.c1.vanguard.com left intact

But when run from another machine, it works:

< HTTP/1.1 200 OK
< Content-Type: application/json
< Content-Length: 152
< Connection: keep-alive
< Cache-Control: private, no-cache, no-store, no-transform, must-revalidate, proxy-revalidate
< Date: Wed, 31 Aug 2022 12:53:44 GMT
< Expires: 0
< Pragma: no-cache
< Server:
< Set-Cookie: XSRF-TOKEN=4315B0A55DE9A185A2F7659040E10050; path=/; domain=.vanguard.com; secure
< Strict-Transport-Security: max-age=31536000 ; includeSubDomains
< X-Content-Type-Options: nosniff
< X-Frame-Options: DENY
< X-XSS-Protection: 1; mode=block
< Vary: accept-encoding
< X-Cache: Miss from cloudfront
< Via: 1.1 2aa70b747c4cbd671958bc7faab603a2.cloudfront.net (CloudFront)
< X-Amz-Cf-Pop: MSP50-C1
< X-Amz-Cf-Id: I2j-8JtZpZ_T-ZkOgC61e8PpqzpMBmxfum1eyCv5PiK3bRNrB63tyg==
<
* Connection #0 to host eds.ecs.gisp.c1.vanguard.com left intact
[{"portId":"7741","accountingTypeCode":46,"priceItem":[{"price":110.33000000,"effectiveDate":"2022-08-26","priceTypeCode":"NAV","currencyCode":"USD"}]}]

Anyone happen to know why that might happen?

Thanks.

Viraj Alankar

unread,
Aug 31, 2022, 1:07:05 PM8/31/22
to Ledger
On Sunday, October 10, 2021 at 3:14:53 PM UTC+2 chrisb...@gmail.com wrote:
The data comes in HTML but this looks like a pretty clean and self-explanatory interface for Vanguard US:

Unfortunately this doesn't work for some funds, for example fund # 7741 which is  "Vanguard Target Retirement 2040 Trust".


On Sat, 9 Oct 2021 at 17:55, Aaron Stacy <aaron....@gmail.com> wrote:
And of course feel free to share if anyone has ideas for getting stuff like this from a proper API 🙂

On Sat, Oct 9, 2021 at 10:54 AM Aaron Stacy <aaron....@gmail.com> wrote:
...and I can answer my own question, but I'll post it here in case it saves anyone else some time:

The JSON API that now works came from inspecting this page, and searching through the XHRs for the NAV price listed. This came up (no headers seem to be needed):

    https://eds.ecs.gisp.c1.vanguard.com/eds-eip-distributions-service/price/daily-nav-history/7743.json?start-date=2021-10-08&end-date=2021-10-09

Where "7743" is the FIID (fund ID? IDK), and while I don't remember where I originally got 7743, I think it was in the malformed OFX export XML from logging into my Vanguard portal.

This works pretty good, but I noticed it has stopped working from some IPs for some reason:


< HTTP/1.1 302 Moved Temporarily
< Transfer-Encoding: chunked
< Connection: keep-alive
< Date: Wed, 31 Aug 2022 12:42:57 GMT
< Cache-Control: no-cache
< Expires: 0
< Location: http://www.vanguard.com/notfound.htm
< Pragma: no-cache
< X-Cache: Miss from cloudfront
< Via: 1.1 2a46367687c8f1815bbea20c92c7d64c.cloudfront.net (CloudFront)
< X-Amz-Cf-Pop: AMS1-P2
< X-Amz-Cf-Id: i5Rwg5vzh336Pk4Zfc9G9l4sX85iKwa75HAvd0Wpr7iU1HhF1Uq1JA==
<
* Curl_http_done: called premature == 0
* Connection #0 to host eds.ecs.gisp.c1.vanguard.com left intact


[{"portId":"7741","accountingTypeCode":46,"priceItem":[{"price":110.33000000,"effectiveDate":"2022-08-26","priceTypeCode":"NAV","currencyCode":"USD"}]}]

Anyone happen to know what might be going on here?

Thanks.
Reply all
Reply to author
Forward
0 new messages