spyse-com / spyse-python

The official wrapper for spyse.com API, written in Python, aimed to help developers build their integrations with Spyse.
https://spyse.com
MIT License
21 stars 11 forks source link

spyse.response.RateLimitError: too many requests #9

Open fabelx opened 2 years ago

fabelx commented 2 years ago
from spyse import Client

def main():
    client = Client("token")
    q = client.get_quotas()

if __name__ == '__main__':
    main()

Traceback:

Traceback (most recent call last):
  File "/home/name/py-trash/privatbank/main.py", line 11, in <module>
    main()
  File "/home/name/py-trash/privatbank/main.py", line 7, in main
    q = client.get_quotas()
  File "/home/name/py-trash/venv/lib/python3.9/site-packages/spyse/client.py", line 106, in get_quotas
    response.check_errors()
  File "/home/name/py-trash/venv/lib/python3.9/site-packages/spyse/response.py", line 117, in check_errors
    raise RateLimitError(m)
spyse.response.RateLimitError: too many requests

Python 3.9.9

Package            Version
------------------ ---------
certifi            2021.10.8
charset-normalizer 2.0.11
dataclasses        0.6
dataclasses-json   0.5.6
idna               3.3
limiter            0.1.2
marshmallow        3.14.1
marshmallow-enum   1.5.1
mypy-extensions    0.4.3
pip                21.2.4
requests           2.26.0
responses          0.13.4
setuptools         58.0.4
six                1.16.0
spyse-python       2.2.3
token-bucket       0.2.0
typing_extensions  4.0.1
typing-inspect     0.7.1
urllib3            1.26.8
wheel              0.37.0
fabaff commented 2 years ago

I see the same with the domain_lookup example:

$ python domain_lookup.py 
Traceback (most recent call last):
  File "/home/fab/Documents/repos/spyse-python/examples/domain_lookup.py", line 8, in <module>
    d = client.get_domain_details('tesla.com')
  File "/home/fab/Documents/repos/spyse-python/spyse/client.py", line 157, in get_domain_details
    response.check_errors()
  File "/home/fab/Documents/repos/spyse-python/spyse/response.py", line 117, in check_errors
    raise RateLimitError(m)
spyse.response.RateLimitError: too many requests
fabaff commented 2 years ago

It looks like that the limiter doesn't cover the first requests (self.account = self.get_quotas()) and the actual request for the data comes to fast.