Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server limit messages are not handled gracefully #45

Open
pmularien opened this issue Nov 13, 2017 · 2 comments
Open

Server limit messages are not handled gracefully #45

pmularien opened this issue Nov 13, 2017 · 2 comments

Comments

@pmularien
Copy link

  • Tiingo Python version: 0.4.0
  • Python version: 3.6
  • Operating System: Windows

Description

API limits enforced at the free tier are not handled gracefully (i.e. error / exception thrown).

What I Did

As expected, once I passed an API limit (not yet a paying customer, though I intend to pay shortly), I received an error because the Tiingo response is not JSON in this case:

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The offending line:

C:\anaconda3-4.2.0\lib\site-packages\tiingo\api.py in get_ticker_price(self, ticker, startDate, endDate, fmt, frequency)
    137         response = self._request('GET', url, params=params)
    138         if fmt == "json":
--> 139             return response.json()
    140         elif fmt == "object":
    141             data = response.json()

This is because the response from the Tiingo API is:

You have run over your 500 symbol look up for this month. Please upgrade at https://api.tiingo.com/pricing to have your limits increased.

... although the HTTP status is still 200 OK (not great API design). Happy to submit a PR if you feel this should be fixed!

@hydrosquall
Copy link
Owner

@pmularien : appreciate you trying out this library, and the detailed bug report! At the very least, we could do a better job of providing a more informative error message, if not having designated logic to handle this rate limiting case.

If you file a PR, I'd be happy to pull it in for the next release :)

For the longer term, @rishi, perhaps usage of a 429 status code might be appropriate: https://softwareengineering.stackexchange.com/questions/128512/suggested-http-rest-status-code-for-request-limit-reached

@hydrosquall
Copy link
Owner

Hi @pmularien - just wanted to ping back to see if you were still interested in picking up this issue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants