williamkray / maubot-ticker

A simple maubot plugin to return basic financial data about stocks and cryptocurrencies
MIT License
5 stars 3 forks source link

Stonks not working anymore #5

Closed borisrunakov closed 2 years ago

borisrunakov commented 2 years ago

Trying with !stonks tsla returns :

pruned_json = resp_json['quoteResponse']['result'][0]
KeyError: 'quoteResponse'
williamkray commented 2 years ago

hmm, i'm not able to replicate this behavior... is this a fresh install?

borisrunakov commented 2 years ago

Yes I just installed, however I remember using the bot in the past in a previous install.

On Fri, Jan 28, 2022, 5:54 PM William Kray @.***> wrote:

hmm, i'm not able to replicate this behavior... is this a fresh install?

— Reply to this email directly, view it on GitHub https://github.com/williamkray/maubot-ticker/issues/5#issuecomment-1024351503, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWF3U2J4CUKRZIUL3B3MPALUYK32HANCNFSM5NAYRJQQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

williamkray commented 2 years ago

my money would be on a typo or other error in the config then... double check the API key you've entered for rapidAPI and make sure it's correct.

my api calls are succeeding, which means that the api itself hasn't changed how they return data or anything like that. the response you're getting isn't matching up with the expected structure, so it errors out. most often, the structure is different than expected because it's not authenticating properly or the call isn't being made right, rather than the api changing anything on their end.

borisrunakov commented 2 years ago

Trying with this from apidojo works:

import http.client

conn = http.client.HTTPSConnection("yh-finance.p.rapidapi.com")

headers = {
    'x-rapidapi-host': "yh-finance.p.rapidapi.com",
    'x-rapidapi-key': "my_api_key"
    }

conn.request("GET", "/auto-complete?q=tesla&region=US", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

Maybe I am not using the correct API ?

williamkray commented 2 years ago

hmm. the bot is configured to connect to apidojo-yahoo-finance-v1.p.rapidapi.com, are you able to send queries to that hostname?

borisrunakov commented 2 years ago

apidojo-yahoo-finance-v1.p.rapidapi.com

Using this I get : {"message":"You are not subscribed to this API."} How is the API called in RapidAPI HUB, so I can register myself ? Currently I am using YH Finance: image

williamkray commented 2 years ago

I'm also using YH Finance. it seems like the host endpoint has changed, but maybe they're allowing old applications to use the old endpoint or something, which is why i'm not seeing the same issues.

this would be so much easier if yahoo published their api themselves instead of using this stupid apidojo service.

i will need to try and make it possible to set the host endpoint in the config file. no guarantees on time, but that seems like hopefully it would fix the issue for new configurations.

borisrunakov commented 2 years ago

That would be great! Thank you very much!

borisrunakov commented 2 years ago

There is also this https://www.yahoofinanceapi.com/

williamkray commented 2 years ago

quick status update, i tried just updating the host to point to the new endpoint, and it seems like the data structure that gets returned is all different. this will take me some time to find a free weekend and basically rewrite this unless someone else wants to do it. :cry:

borisrunakov commented 2 years ago

Thank you very much for the update @williamkray ! I will try if I find some time :(

williamkray commented 2 years ago

closed by https://github.com/williamkray/maubot-ticker/pull/6

snex commented 1 month ago

This is still broken.. There might be a hostname to make it work, but it is not given anywhere. The default one produces the error.