No 204 HTTP status code after exceeding public API request rate limit, but just an empty response

938 views
Skip to first unread message

Sander Jonkers

unread,
Jun 1, 2014, 5:02:59 PM6/1/14
to virus...@googlegroups.com
The virustotal documentations says "Whenever you exceed the public API request rate limit a 204 HTTP status code is returned. ".

However, on the 5th check, I just get an empty response.

Code:

        try:
                req = urllib2.Request(url, data)
                response = urllib2.urlopen(req)
                VTjson = response.read()
except:
print "not good"

print "Start", VTjson, "End"

I would expect an exception on the 5th run, but that does not happen; I just get an empty VTjson.

What are others' experiences?


Emiliano Martinez

unread,
Jun 1, 2014, 5:05:35 PM6/1/14
to virus...@googlegroups.com
Hello Sander,

You get an empty response precisely because you are being rate limited, the body is empty and among the HTTP headers you will find a 204 HTTP status code. Status code travels in the headers of the HTTP protocol, not in its body.

Regards.


--
--
Choose a file, check it with more than 40 antivirus, fast and easy: http://www.virustotal.com

---
You received this message because you are subscribed to the Google Groups "VirusTotal" group.
To unsubscribe from this group and stop receiving emails from it, send an email to virustotal+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sander Jonkers

unread,
Jun 1, 2014, 5:12:03 PM6/1/14
to virus...@googlegroups.com
Ah! It doesn't cause a Python exception... Ah, I changed the code to this:

try:
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
VTjson = response.read()
print "HTTP code is", response.getcode()

... and the result is now as expected:


HTTP code is 200
(True, u' DOS.EiracA.Trojan EICAR-Test-File EICAR-Test-File EICAR.TestFile EICAR test file', 45)

HTTP code is 204
Empty info ...
Something went wrong decoding the JSON info ... over your limit? No JSON object could be decoded


Thank you!
Reply all
Reply to author
Forward
0 new messages