totalvirus-api
Version:
Node.js wrapper for VirusTotal API. Scan files, URLs, and fetch malware analysis reports.
155 lines (107 loc) β’ 3.68 kB
Markdown
# π‘οΈ TotalVirus Scanner
A lightweight, modern, and powerful Node.js wrapper for the [VirusTotal API](https://www.virustotal.com/).
Scan files, scan URLs, and fetch real-time malware analysis β with a single line of code.
> β‘ Plug in your API key once, and you're ready to sniff out threats like a digital hound.
## π§ How It Works
TotalVirus Scanner connects directly with the [VirusTotal v3 API](https://docs.virustotal.com/reference/overview), allowing you to:
- π **Scan files** for malicious content by uploading them
- π **Scan URLs** to detect phishing, malicious redirects, or unsafe domains
- π **Retrieve scan reports** using the analysis ID returned from a scan
All API calls are abstracted into neat promise-based functions for modern, hassle-free integration.
## π¦ Installation
```bash
npm install totalvirus-scanner
```
## π Quick Start
```js
// Import and initialize with your VirusTotal API key
const scanner = require('totalvirus-scanner')('YOUR_API_KEY_HERE');
// Scan a file
scanner.scanFile('./example.exe')
.then(console.log)
.catch(console.error);
// Scan a URL
scanner.scanUrl('https://example.com')
.then(console.log)
.catch(console.error);
// Get a scan report by ID
scanner.getReport('your_analysis_id_here')
.then(console.log)
.catch(console.error);
```
## π§ Available Functions
| Function | Description |
| -----------------------|--------------------------------------------|
| `scanFile(filePath)` | Uploads a file and returns a scan analysis |
| `scanUrl(url)` | Submits a URL for scan and returns analysis|
| `getReport(id)` | Fetches the results of a scan by ID |
## π VirusTotal API Key Setup
To use this package, you need a free VirusTotal API key:
π [Get API Key](https://www.virustotal.com/gui/join-us)
Once you have your key, just pass it once:
```js
const scanner = require('totalvirus-scanner')('YOUR_API_KEY');
```
No need to repeat it β it stays with the session.
## π Folder Structure
```
totalvirus-scanner/
β
βββ index.js # Entry point
βββ api/
β βββ virustotal.js # Core scanning logic
βββ package.json # NPM metadata
βββ README.md # Youβre reading it!
```
## π Sample Output (getReport)
```json
{
"data": {
"id": "u-12345abcd",
"type": "analysis",
"attributes": {
"status": "completed",
"stats": {
"malicious": 1,
"harmless": 68,
"suspicious": 0,
"undetected": 2,
"timeout": 0
}
}
}
}
```
## π§ͺ Test It Locally
```bash
npm install /path/to/your/totalvirus-scanner
```
Then:
```js
const scanner = require('totalvirus-scanner')('your_api_key');
scanner.scanUrl('https://example.com').then(console.log);
```
## π License
MIT License Β© 2025 [Vraj Suratwala](https://github.com/your-github-handle)
## π§ Description (for NPM)
```
A Node.js wrapper for the VirusTotal v3 API. Easily scan files and URLs, and retrieve malware analysis reports in real-time. Plug in your API key once and start scanning securely.
```
## Conclusion
> In the land of code, where threats may hide,
> A tool was forged, with truth as its guide.
> Give it a file, a link, a clue β
> It scans, reveals, and protects you too.
**TotalVirus Scanner** β where scanning is simplified, and malware gets nullified. π₯