[Stock Tracker] ... Error fetching stock data
Extension
https://www.raycast.com/hmarr/stock-tracker
Raycast Version
1.98.4
macOS Version
15.5
Description
Hi! I just downloaded your extension Stock Tracker, but i cant seem to get it to work. I have tried to reinstall it, but it did nothing. When i try to search for a Stock like AAPL or something like that, i get this error:
Steps To Reproduce
- Activate raycast
- Run the View Stocks command.
- Search for something, like AAPL
- Get the error in the image below.
Current Behaviour
Does not receive anything back from Yahoo by the looks of it.
Expected Behaviour
See some info about the Stock.
Thank you for opening this issue!
🔔 @hmarr @ericchernuka you might want to have a look.
💡 Author and Contributors commands
The author and contributors of hmarr/stock-tracker can trigger bot actions by commenting:
@raycastbot close this issueCloses the issue.@raycastbot close as not plannedCloses the issue as not planned.@raycastbot rename this issue to "Awesome new title"Renames the issue.@raycastbot reopen this issueReopens the issue.@raycastbot assign meAssigns yourself to the issue.@raycastbot good first issueAdds the "Good first issue" label to the issue.@raycastbot keep this issue openMake sure the issue won't go stale and will be kept open by the bot.
I recently saw this and haven't had a chance to look into it. Seems like Yahoo may have changed something on their end for how they validate the cookie so I'll look to investigate if there's a workaround.
Ahhh i see, but do you actually need the Cookie? Because i made an iOS app with the same API, and i didn't touch any Cookie things? Is there a reason you need it or could you maybe just remove that part? Thanks anyway for the update and good luck!
Oh interesting! It was there previously and from all the googling it seemed like the way most were doing it.
In your app did you need a API token to leverage it? I think this one is just scrapping the web thus the cookie technique.
Same here 🤚
Ahhh sike, i just looked at how i did it and i was using a cromb, but only for this call: https://query1.finance.yahoo.com/v6/finance/options/(symbol)?cromb=(cromb), whitch no longer works for my either.
Witch API's are you using for the extension and witch is the culprit?
https://github.com/raycast/extensions/blob/main/extensions/stock-tracker/src/yahoo-finance/client.ts
This would be it
I think i found the issue. You just need to add this in HEADERS: "Host": "query2.finance.yahoo.com", in this file: https://github.com/raycast/extensions/blob/main/extensions/stock-tracker/src/yahoo-finance/client.ts.
@MeleMannen quickly tossed that in, but I still get the error. I wonder if the best approach here might be to leverage https://github.com/gadicc/node-yahoo-finance2 to keep pace with updates due to Yahoo's unauthorized detection techniques.
A quick patch to leverage it seemed to get it working again, but I haven't had a chance to really battle test it.
@ericchernuka Yeah that could maybe be smart, but i actually managed to fix it. On my machine at least😅. I just replaced the User-Agent with another one. Very weird and took me a long time to figure out, as i don't have any experience in TypeScript. I just published the fix pending review.
I'll have a look!
I had been playing with randomly selecting a user agent string in order to provide some variability. Shamelessly taken from the python library for Yahoo finance.
Nice! I had to fix a quick format issue, but it should hopefully pass the tests now.
Haha nice. Yeah that could be cool, but some of them obviously don't work. I tried like 3 different ones, before the one that worked. But if one could find more than one that works, it would probably be smart as more people would be using different User-Agent, and therefore a smaller chance for yahoo to block them.
There's some interesting techniques for sure. Just found this in the node one. https://github.com/gadicc/node-yahoo-finance2/blob/devel/src/lib/getCrumb.ts#L303C5-L303C29
Wow! That is genius! That could definitely be worth looking into, especially if it fails again!
I found a problem, witch i am not sure how to fix. The problem is that the stored Crumb is bad, so when it updates, it does not fix the issue. The user will have to reinstall the extension, before it will work. But i am not sure what would be the best fix for this. Is there a way to remove all LocalStorage for that extension when updating it or something like that?
One solution could perhaps be to check if the LocalStorage, of the crumb value, is equal to "Too Many Requests" or something like that, and then delete it if it is.
Or even if the crumb just includes a letter.
Sorry. Haven't had a chance to look yet, but we could probably check the status of the request is over 400 not save it. If we had a previous one, but it's since been invalidated. We should probably clear it, then retry the cookie flow.
Smart! I tried to implement a version of that solution and an attempt at the cool User-Agent. I only included the name as i did not find any version number i could use.