Object

VT module.

class vt.Object(obj_type, obj_id=None, obj_attributes=None)[source]

This class encapsulates any type of object in the VirusTotal API.

Instances of this class are usually obtained from calls to vt.Client.get_object(), however, you need to instantiante this class yourself for creating new objects that will be sent to the backend in a call to vt.Client.post_object().

Learn more about objects in the VirusTotal API in: https://docs.virustotal.com/reference/objects

classmethod from_dict(obj_dict)[source]

Creates an object from its dictionary representation.

The dictionary representation of a VirusTotal API object has the following structure:

{
  "type": <object type>,
  "id": <object id>,
  "links": {
    "self": "https://www.virustotal.com/api/v3/<collection name>/<obj id>"
  },
  "attributes": {
    ...
  }
}

At least type and id are required to be present in the dictionary, if not, an exception is raised.

get(attr_name, default=None)[source]

Returns an attribute by name.

If the attribute is not present in the object, it returns None or the value specified in the “default” argument.

Parameters:
  • attr_name (str) – Name of the attribute.

  • default – An optional value that will be returned if the attribute is not present in the object.

set_data(key, value)[source]

Sets a field of the object’s data.