How to Check if an IP Address is a Known Threat in Go

Cloudmersive
1 min readMar 3, 2022

Filter out known bad IP’s, botnets, compromised servers, and much more with the IP threat detection iteration of our Security API. If you’re working on a project in Go, you can easily use code examples included below to take advantage of this API. For code examples in other common programming languages, check out other articles on our page, or visit our Cloudmersive API Console for 12 additional programming language options.

If you’ve never used a Cloudmersive API before, you’ll need to create an account on our website first to receive an API key. You can make a free-tier account with zero financial commitments, which will supply you with 800 API calls per month, or review additional payment options.

package mainimport (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {url := "https://api.cloudmersive.com/security/threat-detection/network/ip/is-threat"
method := "POST"
payload := strings.NewReader(`"<string>"`)client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Apikey", "YOUR-API-KEY-HERE")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}

--

--

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.