VT module.

class vt.Iterator(client, path, params=None, cursor=None, limit=None, batch_size=0)[source]

Iterator allows iterating over object collections.

Some endpoints in the VirusTotal API represent a collection of objects, for example:



These collections can be iterated using an instance of this class.

Learn more about collections in the VirusTotal API in:

The following example iterates over the most recent 200 comments, retrieving them in batches of 20:

>>> client = vt.Client(<apikey>)
>>> it = client.iterator('/comments', batch_size=20, limit=200)
>>> for comment in it:
>>>   print(comment.text)
>>> print(it.cursor)

When the iteration is done, it print the iterator’s cursor. The cursor can be used for creating another iterator that continues at the point where the previous iterator left.

The Iterator class also exposes an async iterator:

>>>  # Define an async coroutine that iterates over the comments.
>>>  async def print_comments():
>>>    async for comment in client.iterator('/comments', limit=200):
>>>      print(
>>>  # Run the print_comments coroutine using asyncio
>>>  import asyncio
>>>  asyncio.get_event_loop().run_until_complete(print_comments)
property cursor

Cursor indicating the last returned object.

This cursor can be used for creating a new iterator that continues where the current one left.

property meta_async

Meta information.

The cursor is not included, as it’s exposed as a property.