Access the VirusTotal API v3 with managed authentication. Look up files by hash, URLs, domains, and IP addresses, follow their relationships, and read community comments and votes. All access runs through the Maton gateway and the maton CLI.
Permissions
Suggested read access
In the Console, Read limits the connection to these 158 read-only endpoints, plus deny rules for any write endpoint a broader rule would otherwise match. Endpoints Maton has found to return credentials, start jobs, or spend credits are left out; a few reads that can change state or return a secret depending on their parameters stay in, and their descriptions say how. It is a suggestion: the saved rules are exactly the ones you see, and you can change them with Custom. See Access policy.
Reference
Account
Your User
VirusTotal has no me alias: users/{id} takes a user ID or an API key, and users/me returns the VirusTotal user whose ID is me, not the connection's owner. The owner's own user object is looked up by the API key, which stays in the Maton connection, so it isn't fetched through the gateway; the connection's metadata carries the owner's username, first_name, and last_name. Quota and usage endpoints (/api/v3/users/{id}/overall_quotas, /api/v3/users/{id}/api_usage) return 403 through Maton; check quota in the VirusTotal web UI instead.
Files
Get a File Report by Hash
maton api '/virustotal/api/v3/files/{hash}'It can be a SHA-256, SHA-1, or MD5.
Example (the EICAR antivirus test file):
maton api '/virustotal/api/v3/files/275a021bbfb6489e54d471899f7db9d1663fc695ec2fe2a2c4538aabf651fd0f'Response (trimmed):
{
"data": {
"id": "275a021bbfb6489e54d471899f7db9d1663fc695ec2fe2a2c4538aabf651fd0f",
"type": "file",
"attributes": {
"meaningful_name": "eicar.com",
"type_description": "DOS COM",
"size": 68,
"md5": "44d88612fea8a8f36de82e1278abb02f",
"sha1": "3395856ce81f2b7382dee72602f798b642f14140",
"sha256": "275a021bbfb6489e54d471899f7db9d1663fc695ec2fe2a2c4538aabf651fd0f",
"last_analysis_date": 1764000000,
"last_analysis_stats": {"malicious": 62, "suspicious": 0, "undetected": 7, "harmless": 0, "timeout": 0},
"last_analysis_results": {"{engine}": {"category": "malicious", "result": "EICAR-Test-File"}},
"popular_threat_classification": {"suggested_threat_label": "virus.eicar/test"},
"reputation": 3000,
"total_votes": {"harmless": 10, "malicious": 20}
},
"links": {"self": "https://www.virustotal.com/api/v3/files/275a021b..."}
}
}A 404 with "code": "NotFoundError" means VirusTotal has no report for that hash. That is an answer, not a cue to upload the file.
To hash a local file without sending it anywhere:
shasum -a 256 "$USER_SUPPLIED_PATH"Get Objects Related to a File
maton api '/virustotal/api/v3/files/{hash}/{relationship}?limit=10'Use /api/v3/files/{hash}/relationships/{relationship} to get only the related object IDs (descriptors) instead of full objects. Common relationships: comments, votes, contacted_domains, contacted_ips, contacted_urls, dropped_files, execution_parents, bundled_files, itw_urls, behaviours. Many relationships (for example contacted domains and IPs, behaviours, and similar files) need a premium key.
Example:
maton api '/virustotal/api/v3/files/275a021bbfb6489e54d471899f7db9d1663fc695ec2fe2a2c4538aabf651fd0f/relationships/contacted_domains?limit=2'Get Comments and Votes on a File
maton api '/virustotal/api/v3/files/{hash}/comments?limit=10'
maton api '/virustotal/api/v3/files/{hash}/votes?limit=10'Comments and votes are written by VirusTotal community members.
Upload a File for Analysis
For files up to 32 MB. maton api does not build a multipart envelope, so assemble the body first and hand it to --input:
# The assembled body is a copy of the file's bytes, so it is written under /tmp
# and deleted as soon as the upload returns.
FILE="{file_path}"
umask 077
BODY="$(mktemp "${TMPDIR:-/tmp}/vt-upload.XXXXXX")" || exit 1
trap 'rm -f -- "$BODY"' EXIT HUP INT TERM
BOUNDARY="maton-$$"
{
printf -- '--%s\r\nContent-Disposition: form-data; name="file"; filename="%s"\r\nContent-Type: application/octet-stream\r\n\r\n' "$BOUNDARY" "$(basename "$FILE")"
cat "$FILE"
printf -- '\r\n--%s--\r\n' "$BOUNDARY"
} > "$BODY"
maton api -X POST '/virustotal/api/v3/files' \
-H "Content-Type: multipart/form-data; boundary=$BOUNDARY" \
--input "$BODY"An optional password form field lets VirusTotal open a password-protected ZIP. The response is an analysis descriptor:
{
"data": {
"type": "analysis",
"id": "{analysis_id}"
}
}Poll GET /api/v3/analyses/{analysis_id} (below) until it completes, then read the file report by hash.
Get an Upload URL for Large Files
maton api '/virustotal/api/v3/files/upload_url'Returns {"data": "https://bigfiles.virustotal.com/_ah/upload/..."}: a one-time URL for files over 32 MB (up to 650 MB). That URL is on bigfiles.virustotal.com, a host the Maton gateway does not proxy, so the upload itself cannot go through maton api. Treat files over 32 MB as out of scope for this connection.
Request a File Rescan
maton api -X POST '/virustotal/api/v3/files/{hash}/analyse'URLs
Get a URL Report
maton api '/virustotal/api/v3/urls/{url_id}'{url_id} is the URL encoded as unpadded URL-safe base64 (VirusTotal canonicalizes it server-side), or the SHA-256 that VirusTotal returns as the URL object's id. Computing it uploads nothing:
python3 -c 'import base64, sys; print(base64.urlsafe_b64encode(sys.argv[1].encode()).decode().rstrip("="))' 'https://www.google.com/'Example:
maton api '/virustotal/api/v3/urls/aHR0cHM6Ly93d3cuZ29vZ2xlLmNvbS8'Response (trimmed):
{
"data": {
"id": "d0e196a0c25d35dd0a84593cbae0f38333aa58529936444ea26453eab28dfc86",
"type": "url",
"attributes": {
"url": "https://www.google.com/",
"last_final_url": "https://www.google.com/",
"title": "Google",
"last_http_response_code": 200,
"last_analysis_stats": {"malicious": 0, "suspicious": 0, "undetected": 25, "harmless": 70, "timeout": 0},
"categories": {"{engine}": "search engines"},
"reputation": 0
}
}
}Related objects use the same pattern as files: /api/v3/urls/{url_id}/{relationship} (for example comments, votes, last_serving_ip_address, redirecting_urls, network_location).
Submit a URL for Scanning
maton api -X POST '/virustotal/api/v3/urls' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--input - <<'BODY'
url=https%3A%2F%2Fexample.com%2F
BODYThe url value must be URL-encoded. The response is an analysis descriptor (data.type is analysis); poll it with GET /api/v3/analyses/{analysis_id}.
To rescan a URL VirusTotal already has:
maton api -X POST '/virustotal/api/v3/urls/{url_id}/analyse'Analyses
Get an Analysis
maton api '/virustotal/api/v3/analyses/{analysis_id}'Use the id returned by a file or URL submission.
data.attributes.status is queued, in-progress, or completed; once completed, stats holds the verdict counts and results the per-engine results. meta.file_info or meta.url_info identifies the analysed item. Poll no faster than the key's rate limit allows (once every 15 seconds or slower on a free key).
Domains
Get a Domain Report
maton api '/virustotal/api/v3/domains/{domain}'Example:
maton api '/virustotal/api/v3/domains/google.com'Response (trimmed):
{
"data": {
"id": "google.com",
"type": "domain",
"attributes": {
"registrar": "MarkMonitor Inc.",
"creation_date": 874296000,
"last_analysis_stats": {"malicious": 0, "suspicious": 0, "undetected": 28, "harmless": 66, "timeout": 0},
"categories": {"{engine}": "searchengines"},
"last_dns_records": [{"type": "A", "value": "142.250.0.0", "ttl": 300}],
"reputation": 600,
"tags": []
}
}
}Get Objects Related to a Domain
maton api '/virustotal/api/v3/domains/{domain}/{relationship}?limit=10'Common relationships: resolutions (passive DNS), subdomains, siblings, parent, comments, votes, communicating_files, downloaded_files, referrer_files, urls, historical_whois, historical_ssl_certificates. Some need a premium key. /api/v3/domains/{domain}/relationships/{relationship} returns descriptors only.
Examples:
maton api '/virustotal/api/v3/domains/google.com/resolutions?limit=2'
maton api '/virustotal/api/v3/domains/google.com/relationships/subdomains?limit=2'IP Addresses
Get an IP Address Report
maton api '/virustotal/api/v3/ip_addresses/{ip}'Example:
maton api '/virustotal/api/v3/ip_addresses/8.8.8.8'The attributes include as_owner, asn, country, network, last_analysis_stats, last_analysis_results, reputation, and whois.
Get Objects Related to an IP Address
maton api '/virustotal/api/v3/ip_addresses/{ip}/{relationship}?limit=10'Common relationships: comments, votes, resolutions, communicating_files, downloaded_files, referrer_files, urls, historical_whois, historical_ssl_certificates.
Example:
maton api '/virustotal/api/v3/ip_addresses/8.8.8.8/comments?limit=1'Search
maton api '/virustotal/api/v3/search?query={query}'The basic search takes a file hash, URL, domain, IP address, or comment tag and returns the matching objects. Content and property searches (/api/v3/intelligence/search) need a premium VirusTotal Intelligence key.
Example:
maton api '/virustotal/api/v3/search?query=8.8.8.8'Pagination
Collections and relationships take limit (at most 40) and cursor. The response carries meta.cursor and links.next while more results exist:
maton api '/virustotal/api/v3/domains/google.com/resolutions?limit=10'
maton api '/virustotal/api/v3/domains/google.com/resolutions?limit=10&cursor={cursor}'Each page is one request against the key's quota, so do not walk long relationship lists on a free key.
Notes
- Free (public) API key limits: 4 requests per minute, 500 per day, and 15.5K per month. Space calls at least 15 seconds apart on a free key, and treat a
429(QuotaExceededError) as a signal to wait, not to retry immediately. The public API must not be used in commercial products or business workflows. - Premium-only features: VirusTotal Intelligence search, file downloads, Hunting (YARA Livehunt, Retrohunt), feeds, and extended relationships and metadata. These return
403on a free key. - File IDs are SHA-256, SHA-1, or MD5; domain IDs are the domain; IP IDs are the address; URL IDs are unpadded base64 or SHA-256.
- Timestamps are Unix epoch seconds.
- Errors carry
{"error": {"code": "...", "message": "..."}}, e.g.NotFoundError(404),QuotaExceededError(429),ForbiddenError(403),WrongCredentialsError(401). - Comments and votes can also be posted, publicly under the key owner's VirusTotal identity; that is out of scope for this reference.