hydrosquall / hydrosquall/tiingo-python

Server limit messages are not handled gracefully

Open
#45 2 comments 0 reactions 0 assignees View on GitHub
bug help wanted
Dominant language
Python
Stars
319
Forks
58
PR merge metrics
No merged PRs in 30d

Description

* 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!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.