Examples

This page contains examples of all the features available as part of this implementation. Use this page for reference for use of this API.

How to use API

These are the different types of API usees:

Sending and scanning files

Example 1: File

            
                package main
                
                import "me/vighnesh/api/virustotal"
                import "fmt"
                
                func main() {
                    virustotalapi, _ := virustotal.Configure("APIKEY")
                
                    response, e := virustotalapi.ScanFile("FILE TO SCAN")
                    if e != nil {
                        fmt.Println(e)
                    }
                    fmt.Println("Verbose Message", response.Message)
                    fmt.Println("SHA-1", response.Sha1)
                    fmt.Println("SHA-256", response.Sha256)
                    fmt.Println("MD5", response.Md5)
                    fmt.Println("Permalink", response.Permalink)
                    fmt.Println("Resource", response.Resource)
                    fmt.Println("ScanId", response.ScanId)
                    fmt.Println("Response Code", response.ResponseCode)
                }                
                    
                 
        

Example 2: File as Stream

        
            package main
            
            import "me/vighnesh/api/virustotal"
            import "fmt"
            
            func main() {
                virustotalapi, _ := virustotal.Configure("APIKEY")
                response, e := virustotalapi.ScanFileStream("File Name", "File Stream or io.Reader")
                if e != nil {
                    fmt.Println(e)
                }
                fmt.Println("Verbose Message", response.Message)
                fmt.Println("SHA-1", response.Sha1)
                fmt.Println("SHA-256", response.Sha256)
                fmt.Println("MD5", response.Md5)
                fmt.Println("Permalink", response.Permalink)
                fmt.Println("Resource", response.Resource)
                fmt.Println("ScanId", response.ScanId)
                fmt.Println("Response Code", response.ResponseCode)
            }
            
        
        

Rescanning already submitted files

Example 1:

          
package main

import "me/vighnesh/api/virustotal"
import "fmt"

func main() {
	virustotalapi, _ := virustotal.Configure("APIKEY")
	response, e := virustotalapi.ReScanFile("Resorce")
	if e != nil {
		fmt.Println(e)
	}
	fmt.Println("Verbose Message", response.Message)
	fmt.Println("SHA-1", response.Sha1)
	fmt.Println("SHA-256", response.Sha256)
	fmt.Println("MD5", response.Md5)
	fmt.Println("Permalink", response.Permalink)
	fmt.Println("Resource", response.Resource)
	fmt.Println("ScanId", response.ScanId)
	fmt.Println("Response Code", response.ResponseCode)
}

          
          

Retrieving file scan reports

Example 1:

        
            package main
            
            import "me/vighnesh/api/virustotal"
            import "fmt"
            
            func main() {
                virustotalapi, _ := virustotal.Configure("APIKEY")
                response, e := virustotalapi.FileReport("Resource")
                if e != nil {
                    fmt.Println(e)
                }
            
                for engine, report := range response.Scans {
                    fmt.Println("Scan Engine", engine)
                    if report.Detected {
                        fmt.Println("Version", report.Version)
                        fmt.Println("Updated", report.Update)
                        fmt.Println("Malware", report.Malware)
                    } else {
                        fmt.Println("No Malware Detected")
                    }
            
                }
            }
            
        
        

Sending and scanning URLs

Example 1:

        
            package main
            
            import "me/vighnesh/api/virustotal"
            import "fmt"
            
            func main() {
                virustotalapi, _ := virustotal.Configure("APIKEY")
                response, e := virustotalapi.ScanURL("vighnesh.me")
                if e != nil {
                    fmt.Println(e)
                }
            
                fmt.Println("Verbose Message", response.Message)
                fmt.Println("SHA-1", response.Sha1)
                fmt.Println("SHA-256", response.Sha256)
                fmt.Println("MD5", response.Md5)
                fmt.Println("Permalink", response.Permalink)
                fmt.Println("Resource", response.Resource)
                fmt.Println("ScanId", response.ScanId)
                fmt.Println("Response Code", response.ResponseCode)
            }            

        
        

Retrieving URL scan reports

Example 1:

        
            package main
            
            import "me/vighnesh/api/virustotal"
            import "fmt"
            
            func main() {
                virustotalapi, _ := virustotal.Configure("APIKEY")
                response, e := virustotalapi.URLReport("vighnesh.me")
                if e != nil {
                    fmt.Println(e)
                }
            
                for engine, report := range response.Scans {
                    fmt.Println("Scan Engine", engine)
                    if report.Detected {
                        fmt.Println("Version", report.Version)
                        fmt.Println("Updated", report.Update)
                        fmt.Println("Malware", report.Malware)
                    } else {
                        fmt.Println("No Malware Detected")
                    }
            
                }
            }            

        
        

Retrieving IP address reports

Example:

        
            package main
            
            import "me/vighnesh/api/virustotal"
            import "fmt"
            
            func main() {
                virustotalapi, _ := virustotal.Configure("APIKEY")
                response, e := virustotalapi.IPReport("90.156.201.27")
                if e != nil {
                    fmt.Println(e)
                }
                fmt.Println("Resolutions", response.Resolutions)
                fmt.Println("Detected", response.DetectedUrls)
            }
            
        
        

Retrieving domain reports

Example:

        
            package main
            
            import "me/vighnesh/api/virustotal"
            import "fmt"
            
            func main() {
                virustotalapi, _ := virustotal.Configure("APIKEY")
                response, e := virustotalapi.DomainReport("vighnesh.me")
                if e != nil {
                    fmt.Println(e)
                }
                fmt.Println("Resolutions", response.Resolutions)
                fmt.Println("Detected", response.DetectedUrls)
            }            

        
        

Make comments on files and URLs

Example:

        
            package main
            
            import "me/vighnesh/api/virustotal"
            import "fmt"
            
            func main() {
                virustotalapi, _ := virustotal.Configure("APIKEY")
                response, e := virustotalapi.Comment("Resource", "Good File")
                if e != nil {
                    fmt.Println(e)
                }
            
                fmt.Println("Response Code", response.ResponseCode)
                fmt.Println("Message", response.Message)
            }
            
        
        

Comments

User Name

Description

Priority

Issue