AlienVault-OTX / OTX-Python-SDK

The Python SDK for AlienVault OTX
Other
359 stars 162 forks source link

getall API not working ! #69

Open AnduinBrian opened 1 year ago

AnduinBrian commented 1 year ago

Here is my snippet:

from OTXv2 import OTXv2
from OTXv2 import IndicatorTypes

otx = OTXv2("xxxx")
pulses = otx.getall()
print(len(pulses))

the output:

Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\requests\adapters.py", line 486, in send        
    resp = conn.urlopen(
  File "C:\Python39\lib\site-packages\urllib3\connectionpool.py", line 878, in urlopen
    return self.urlopen(
  File "C:\Python39\lib\site-packages\urllib3\connectionpool.py", line 878, in urlopen
    return self.urlopen(
  File "C:\Python39\lib\site-packages\urllib3\connectionpool.py", line 878, in urlopen
    return self.urlopen(
  [Previous line repeated 2 more times]
  File "C:\Python39\lib\site-packages\urllib3\connectionpool.py", line 868, in urlopen
    retries = retries.increment(method, url, response=response, _pool=self)
  File "C:\Python39\lib\site-packages\urllib3\util\retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='otx.alienvault.com', port=443): Max retries exceeded with url: /api/v1/pulses/subscribed?limit=50 (Caused by ResponseError('too many 504 error responses'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\OTXv2.py", line 178, in get
    response = self.session().get(
  File "C:\Python39\lib\site-packages\requests\sessions.py", line 600, in get
    return self.request("GET", url, **kwargs)
  File "C:\Python39\lib\site-packages\requests\sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Python39\lib\site-packages\requests\sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python39\lib\site-packages\requests\adapters.py", line 510, in send
    raise RetryError(e, request=request)
requests.exceptions.RetryError: HTTPSConnectionPool(host='otx.alienvault.com', port=443): Max retries exceeded with url: /api/v1/pulses/subscribed?limit=50 (Caused by ResponseError('too many 504 error responses'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Chipuku\Desktop\OTX automation\auto_otx.py", line 5, in <module>
    pulses = otx.getall()
  File "C:\Python39\lib\site-packages\OTXv2.py", line 404, in getall
    return self.walkapi(
  File "C:\Python39\lib\site-packages\OTXv2.py", line 385, in walkapi
    return list(self.walkapi_iter(url, max_page=max_page, max_items=max_items, method=method, body=body))
  File "C:\Python39\lib\site-packages\OTXv2.py", line 366, in walkapi_iter
    data = self.get(next_page_url)
  File "C:\Python39\lib\site-packages\OTXv2.py", line 187, in get
    raise RetryError()
OTXv2.RetryError: 'Exceeded maximum number of retries'

Why is that happend ?

swannie-eire commented 8 months ago

Here is my snippet:

from OTXv2 import OTXv2
from OTXv2 import IndicatorTypes

otx = OTXv2("xxxx")
pulses = otx.getall()
print(len(pulses))

the output:

Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\requests\adapters.py", line 486, in send        
    resp = conn.urlopen(
  File "C:\Python39\lib\site-packages\urllib3\connectionpool.py", line 878, in urlopen
    return self.urlopen(
  File "C:\Python39\lib\site-packages\urllib3\connectionpool.py", line 878, in urlopen
    return self.urlopen(
  File "C:\Python39\lib\site-packages\urllib3\connectionpool.py", line 878, in urlopen
    return self.urlopen(
  [Previous line repeated 2 more times]
  File "C:\Python39\lib\site-packages\urllib3\connectionpool.py", line 868, in urlopen
    retries = retries.increment(method, url, response=response, _pool=self)
  File "C:\Python39\lib\site-packages\urllib3\util\retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='otx.alienvault.com', port=443): Max retries exceeded with url: /api/v1/pulses/subscribed?limit=50 (Caused by ResponseError('too many 504 error responses'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\OTXv2.py", line 178, in get
    response = self.session().get(
  File "C:\Python39\lib\site-packages\requests\sessions.py", line 600, in get
    return self.request("GET", url, **kwargs)
  File "C:\Python39\lib\site-packages\requests\sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Python39\lib\site-packages\requests\sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python39\lib\site-packages\requests\adapters.py", line 510, in send
    raise RetryError(e, request=request)
requests.exceptions.RetryError: HTTPSConnectionPool(host='otx.alienvault.com', port=443): Max retries exceeded with url: /api/v1/pulses/subscribed?limit=50 (Caused by ResponseError('too many 504 error responses'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Chipuku\Desktop\OTX automation\auto_otx.py", line 5, in <module>
    pulses = otx.getall()
  File "C:\Python39\lib\site-packages\OTXv2.py", line 404, in getall
    return self.walkapi(
  File "C:\Python39\lib\site-packages\OTXv2.py", line 385, in walkapi
    return list(self.walkapi_iter(url, max_page=max_page, max_items=max_items, method=method, body=body))
  File "C:\Python39\lib\site-packages\OTXv2.py", line 366, in walkapi_iter
    data = self.get(next_page_url)
  File "C:\Python39\lib\site-packages\OTXv2.py", line 187, in get
    raise RetryError()
OTXv2.RetryError: 'Exceeded maximum number of retries'

Why is that happend ?

you are hit API limits.

Be more specific e.g pulses = otx.getall(author_name='VertekLabs', max_items=200, max_page=4)