Virusscan via API

How to use the virusscanner trough the TTA HTTP API.

Virus scanning via API

import axios from "axios";
import FormData from "form-data";
import { readFileSync } from "fs";

const data = new FormData();
data.append('file', readFileSync('path/to/file'), {
  filename: 'FileName',
  contentType: 'MimeType'
});

const options = {
  method: 'POST',
  url: 'https://virusscan-texttoanything.p.rapidapi.com/virusScan',
  headers: {
    'x-rapidapi-key': '{Your-RapidAPI-Key}',
    ...data.getHeaders(),
  },
  data: data
};

const response = await axios.request(options);
console.log(response.data);

The body of the request should be a multipart/form-data object with as "file" the file that you want to scan. The API will return the JSON in the specified format.

Query parameters:

OptionTypeDescription
filefile The file that you want to have scanned

Output

When the file has no virus:
{
  "isInfected": false,
  "viruses": [],
  "timeout": false
}
When the file has a virus:
{
  "isInfected": true,
  "viruses": [
    "Eicar-Signature"
  ],
  "timeout": false
}