Polite VirusTotal Public API v3 client
Project description
vtfree
Cliente ligero, prudente y tipado para la VirusTotal Public API v3.
Características
| Descripción |
|---|
| Emplea varias API keys a la vez, rotándolas y revisando que no sobrepasen cuotas. |
| Respeta la cuota pública (4 req/min · 500 req/día) mediante un token‑bucket por API‑Key. |
Rotación automática de claves y detección de códigos 429 / “User banned”. |
Logging rotativo UTF‑8 (~/.vtfree/vtfree.log, 2 MB × 3). |
Tipado estático (compatible ‑strict con mypy). |
API orientada a objetos (VTClient) más wrappers retro‑compatibles (check_urls_in_vt, etc.). |
Solo depende de requests y opcionalmente python‑dotenv. |
Instalación
pip install vtfree # versión estable desde PyPI
# o, para desarrollo:
pip install -e .[dev] # dentro del repo clonado
Configuración de claves
-
Añade tus claves públicas en un
.envseparadas por comas, sin ponerlas entre comillas:VT_KEYS=key1,key2,key3,key4
-
Carga el fichero
.enval arrancar tu script:from dotenv import load_dotenv load_dotenv()
Uso básico
import os, vtfree.log
from dotenv import load_dotenv
from vtfree import VTClient
load_dotenv()
vtfree.log.configure() # ~/.vtfree/vtfree.log
keys = os.getenv("VT_KEYS", "").split(",")
vt = VTClient(keys, validate=True) # smoke‑test opcional
report = vt.file_report("99017f6eebbac24f351415dd410d522d")
print(report["data"]["attributes"]["type"]) # 'file'
print(vt.key_status()) # snapshot de cuotas
Wrappers de compatibilidad (scripts heredados)
from vtfree.contrib import (
set_default_client, check_urls_in_vt,
check_ips_in_vt, check_domains_in_vt,
check_hashes_in_vt,
)
set_default_client(vt) # usa la instancia ya creada
res = []
res += check_urls_in_vt([
"http://homespottersf.com/sm/googledocs1/index.html",
"https://undec-ab94.djuleircendku.workers.dev/b96043f6-39ae-43f3-aef7-d1371cf249e8",
])
res += check_ips_in_vt(["66.240.205.34"])
res += check_domains_in_vt(["karasserybank.com", "iownyour.biz"])
res += check_hashes_in_vt(["e0c0cbc50a9ed4d01a176497c8dba913cbbba515ea701a67ef00dcb7c8a84368"])
for r in res:
print(r)
Ejemplo de salida:
{'ioc_type': 'url', 'score': '3/24', 'ioc': 'http://homespottersf.com/...', ...}
{'ioc_type': 'ip', 'score': '13/35', 'ioc': '66.240.205.34', ...}
{'ioc_type': 'domain', 'score': '0/22', 'ioc': 'karasserybank.com', ...}
Registro de eventos
2025‑04‑21 19:12:01 INFO vtfree.client Key 0900…21cf → HTTP 200
2025‑04‑21 19:12:16 DEBUG vtfree.client Key status: [{'key': '0900…21cf', ...}]
Ubicación: ~/.vtfree/vtfree.log (UTF‑8, rotación 2 MB × 3).
Para registrar en otra ruta o cambiar el nivel:
vtfree.log.configure(path="vtfree_debug.log", level=10) # DEBUG
Buenas prácticas con la cuota gratuita
| Regla VirusTotal | Implementación en vtfree |
|---|---|
| 4 peticiones / minuto | Token‑bucket deslizante de 60 s por API‑Key. |
| 500 peticiones / día | Contador diario reiniciado a las 00:00 UTC. |
429 → esperar |
Marca la clave como BANNED, pasa a la siguiente y hace back‑off de 15 s. |
Licencia
MIT © 2025 Nand0san — puedes usar esta librería en proyectos comerciales y open‑source manteniendo la nota de copyright.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vtfree-0.1.1.tar.gz.
File metadata
- Download URL: vtfree-0.1.1.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
147417514fcaa75a69f176474c3ee54f6321c5524851c87ce78efa95d0d7c6a2
|
|
| MD5 |
199b5ed7912f4e7c2b258096a1863e1e
|
|
| BLAKE2b-256 |
c06e0613fe9dc0c065d9c165f512ad0a81d410b40aa3ba3f1583de0e416d74ee
|
File details
Details for the file vtfree-0.1.1-py3-none-any.whl.
File metadata
- Download URL: vtfree-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc1cbf2ba8b89a6cf3fad858315a082920f27b3d830af19971e93f0643a720f5
|
|
| MD5 |
82909e5be78f62ec78b442a17c3a578a
|
|
| BLAKE2b-256 |
df696bde352adebcc9a905cefde8181ea2bbfc00b1be31c4fe3b6e020241b01f
|