piquette/finance-go

YFinance changed their api's (or their security)

TobiasFP opened this issue · 32 comments

Hi.
There seams to be an issue with the finance-go, since yFinance changed its encryption keys.
Apparantly they change their encryption keys every day or even sometimes more than once a day.
This has lead to finance-go not working for a while.
yFinance has the same issue:
ranaroussi/yfinance#1407

I just wanted to bring it to your attention. I have been very happy with this library, so thank you very much for your work.

ktpx commented

v6 of the API seems to work, not 7.

@ktpx You saved me! :)

ktpx commented

I think they pulled the plug on v6 now. :(

joce commented

All projects I see using the Yahoo API are facing this. There is this nugget I got from the ticker issue report on the subject:

https://stackoverflow.com/questions/76065035/yahoo-finance-v7-api-now-requiring-cookies-python

Not sure how/if that helps...

Saw somewhere that for instance, an url like this:
https://query2.finance.yahoo.com/v6/finance/quoteSummary/AAPL?modules=financialData
is working, but I'm not sure if the data structures are the same.
Is someone working on a patch?

joce commented

achannarasappa/ticker#250 (comment)
Looks like we're out of luck. 😢

ktpx commented

Saw somewhere that for instance, an url like this: https://query2.finance.yahoo.com/v6/finance/quoteSummary/AAPL?modules=financialData is working, but I'm not sure if the data structures are the same. Is someone working on a patch?

Totally different structure than the quotes. This show financial data. But atleast one can grab the currentprices.

Crumb is a param that is easy to gain, not sure how it will behave in long term.

For now, it is possible to generate crumb via https://query2.finance.yahoo.com/v1/test/getcrumb and then pass crumb value as param https://query2.finance.yahoo.com/v7/finance/quote?symbols=AAPL&crumb=abcdef.g. (Works with v7 only)

I have had the same crumb for a few days now, so it's possible to cache it locally on disk to avoid this call.

ktpx commented

If you inspect the cookie header, it says one year. "Expires=Wed, 5 Jun 2024 22:54:09 GMT"

Hi there, is there any workaround I could use to test ? This is broken for a while.

joce commented

So I have a fix for this and I have opened a PR for it. Not sure who should be reviewing it.
I also have "modernized" the finance-mock project used to test finance-go. PR can be found here: piquette/finance-mock#1

I would love to review it, but i don't think we can get it in as i think the project is dead here. Maybe fork?

joce commented

Is it, though? There were a couple of PR that were merged a month ago by @ackleymi .

My bad. Just add me to the pr if you want

joce commented

Doesn't look like I can add you, but feel free to head over the the PR and comment on it: #28

Doesn't look like I can add you, but feel free to head over the the PR and comment on it: #28

Done. Good job!

ktpx commented

Did they add some kind of rate limit? I don't get a crumb anymore, just "Too many requests".

joce commented
ktpx commented

I don't have access to a machine with the library on it atm. I'll check about this later today.

On Thu, Jul 20, 2023 at 3:32 PM ktpx @.> wrote: Did they add some kind of rate limit? I don't get a crumb anymore, just "Too many requests". — Reply to this email directly, view it on GitHub <#25 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAATT2NOHUSYZVJRSGVCHALXRGBTHANCNFSM6AAAAAAVGDRPD4 . You are receiving this because you commented.Message ID: @.>

Not a software issue really, API.

curl  https://query2.finance.yahoo.com/v1/test/getcrumb
Too Many Requests

Thats atleast the URL i used in my progs

joce commented
ktpx commented

I do set cookie in the code, curl was bad example. But I still get same error. It worked, and literary didnt work half hour later, no code changed, so gotta be something yahoo changed.

joce commented
ktpx commented

Which site do you query to get the cookie? Seems might be the problem. Ive used fc.yahoo.com, as its the only one that worked for me. For regular api calls, query2.

joce commented
ktpx commented

Ok using login subdomain again got me the cookie, but still no crum. Mind showing your crumb URL.....? I didnt find it in the source

joce commented

I will refer you to my pull request:

#28

You should be able to get everything you need there.

ktpx commented

Thanks, its same url. Im guessing they are doing some IP based limiting, or blocking, im just getting the too many requests from here (EU).

joce commented

Have you sync'd my branch and run the examples program?

ktpx commented

Ok, confirmed is a location issue. So ill assume people using this tool wil also have
problem if aren't in US.

So, that means this solution is only working if the request is made in the US?

ktpx commented

So, that means this solution is only working if the request is made in the US?

For the quotes API, it seems so yes. But I can't speak for other countries. But ive tried in 3 different EU countries, and no dice. It worked for a while, but no more.

Hi @ackleymi , I saw that #28 was merged in, but there's no new tag or release with this change. Are there any plans to formally release this change? Thanks!