Snapshot class

class Snapshot(version=None, spec_version=None, expires=None, meta=None, unrecognized_fields=None)

A container for the signed part of snapshot metadata.

Snapshot contains information about all target Metadata files.

All parameters named below are not just constructor arguments but also instance attributes.

  • version (Optional[int]) – Metadata version number. Default is 1.

  • spec_version (Optional[str]) – Supported TUF specification version. Default is the version currently supported by the library.

  • expires (Optional[datetime]) – Metadata expiry date. Default is current date and time.

  • unrecognized_fields (Optional[Dict[str, Any]]) – Dictionary of all attributes that are not managed by TUF Metadata API

  • meta (Optional[Dict[str, MetaFile]]) – Dictionary of targets filenames to MetaFile objects. Default is a dictionary with a Metafile for “snapshot.json” version 1.


ValueError – Invalid arguments.

property expires: datetime

The metadata expiry date:

# Use 'datetime' module to e.g. expire in seven days from now
obj.expires = utcnow() + timedelta(days=7)

Checks metadata expiration against a reference time.


reference_time (Optional[datetime]) – Time to check expiration date against. A naive datetime in UTC expected. Default is current UTC date and time.


True if expiration time is less than the reference time.

Return type