skip to Main Content

I am trying to scan multiple URLs on Virustotal.com using APIs.

This is how Virustotal has defined how to send API requests.

curl –request POST
url https://www.virustotal.com/api/v3/urls
header ‘x-apikey: ‘your API key’
form url=’url’

Please let me know how I can use this in a javascript file.

2

Answers


  1. You can use fetch() : a web API that lets you make asynchronous requests.
    It returns a “Promise” which is one of the great features of ES6. All though there are other ways too here : https://www.freecodecamp.org/news/here-is-the-most-popular-ways-to-make-an-http-request-in-javascript-954ce8c95aaa/

    const url= "https://www.virustotal.com/api/v3/urls";
        
          const otherParameters = {
              headers :{
                "content-type": "application/json",
                "x-api-key": "your API key"
              },
              method:"POST"
          }
        
          fetch(url,otherParameters)
          .then(data=>return data.json())
          .then(res=> console.log(res))
          .catch(error=> console.log(error));
    
    Login or Signup to reply.
  2. Try to use XMLHttpRequest,it’s a better than jQuery

    
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function () {
        if (this.readyState == 4 && this.status == 200) {
            data = JSON.parse(this.responseText);
    
            for (let i in data) {
    
    
              console.log(data[i])
            }
        }
    };
    xhttp.setRequestHeader("content-type", "application/json")
    xhttp.setRequestHeader("x-api-key", "your API key")
    
    xhttp.open("POST", "https://www.virustotal.com/api/v3/urls", true);
    xhttp.send();
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search