Skip to main content
Question

How to export All result from API without hitting the rate limit

  • Dec 15, 2024 5:49 AM UTC
  • 4 replies
  • 442 views

Hi,

I have a query which return 200K hosts. I need to download all.

if I use the following code, after 300 query rate limit will stop the script.

query = h.search ("SEARCH TERM", per_page=100, pages=-1)

Also I used another approach, which download lots of repetitive data

for page in range(1, 100):
query = h.search(    'services.port: 80 AND services.tls.certificates: * AND services.http.response.status_code: 403',    per_page=100, page=page)

 

any IDEA how to download all data without problem.

4 replies

MattK_Censys
Forum|alt.badge.img+2
  • Censys Community Manager
  • Dec 16, 2024 4:08 PM UTC

Hey Mari, I checked with our team and I think you need to add a time.sleep(1) function to your code. Here’s a bit of info about that: https://www.digitalocean.com/community/tutorials/python-time-sleep

Let me know if that helps.


  • Author
  • New Participant
  • Dec 16, 2024 6:15 PM UTC

I have sleep(2) in my code after each API call, but I don’t know why I got redundant data. I lose half of my quota because of this.


MattK_Censys
Forum|alt.badge.img+2
  • Censys Community Manager
  • Dec 16, 2024 6:40 PM UTC

Hey again Mari, to help further we’d need to see the full code you’re using as well as examples of the redundant data. Please feel free to open a support ticket or message me directly with that info.


  • Author
  • New Participant
  • Dec 16, 2024 7:28 PM UTC

thanks, just opened a ticket.