Python Historics API


#1

Hello everyone,

I’m trying to use the Python implementation found on Datasift’s Github. I created my account, activated Twitter & Facebook Public for the streams. I created a simple query stream on Datasift’s site and it works !

But when I want to use the historics.py sample found on Datasift’s Github, I get this error :

python historics_api.py
Check the data coverage for the last two hours
Traceback (most recent call last):
File “historics_api.py”, line 15, in
status = datasift.historics.status(start, end_time)
File “/usr/local/lib/python2.7/dist-packages/datasift/historics.py”, line 102, in status
return self.request.get(‘status’, params=params)
File “/usr/local/lib/python2.7/dist-packages/datasift/request.py”, line 39, in get
return self.build_response(self(‘get’, path, params=params, headers=headers), path=path)
File “/usr/local/lib/python2.7/dist-packages/datasift/request.py”, line 84, in build_response
if int(response.headers.get(“x-ratelimit-cost”)) > int(response.headers.get(“x-ratelimit-remaining”)):
TypeError: int() argument must be a string or a number, not ‘NoneType’

Well, I don’t know where it’s malfunctionning, and by commenting every problematic line, I realize that each time that I call datasift.historics, i get this error…

Here’s the python code for the historics_api.py : https://github.com/datasift/datasift-python/blob/develop/examples/historics_api.py (of course I logged in and put my username/API key !)

I am under Ubuntun GNOME 3 & using Python 27 (i get syntax error under Python 32 :/)

Thanks !


#2

Hi,

Thanks for reporting this, it may have been a tranisent issue with the API that was causing the error. Do you still get the same problem if you run it again? Also note that the library Supports Python 2.6, 2.7 and 3.3. 

If you still have problems I would recommed raising a support ticket over on our support site so we can dig a bit deeper.