How to Check if an Address is a Bot Client Threat in Go

Cloudmersive
1 min readMar 3, 2022

--

Incorporate our Security API’s real-time signals into your project easily with a free Cloudmersive Account. With the code examples below, you can equip your Go project to check input IP addresses for bots, robots, or any non-user entities. Check out the Cloudmersive API Console to find code in 12 other common programming languages, or visit our YouTube channel to learn how you can use our Security API & many others via Power Automate.

Before you begin copying the below, first create a free account on our website (www.cloudmersive.com) to receive an API key with 800 free API calls per month. After that, it’s smooth sailing.

package mainimport (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {url := "https://api.cloudmersive.com/security/threat-detection/network/ip/is-bot"
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
Cloudmersive

Written by Cloudmersive

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

No responses yet