pricing background

Go API Integration

api

Geolocation Lookup

package main

import (
	"fmt"
	"net/http"
	"strings"
	"io/ioutil"
)

func main() {
	var payload *strings.Reader = nil
	req, _ := http.NewRequest("GET", "https://api.whoisfreaks.com/v1.0/geolocation?apiKey=API_KEY&ip=8.8.8.8", payload)
	client := &http.Client{}
	resp, _ := client.Do(req)
	defer resp.Body.Close()
	body, _ := ioutil.ReadAll(resp.Body)
	fmt.Println(string(body))
}

Bulk Geolocation Lookup

package main

import (
	"fmt"
	"net/http"
	"strings"
	"io/ioutil"
)

func main() {
	payload := strings.NewReader("{"ips":["1.1.1.1","2.2.2.2","8.8.8.8"]}")
	req, _ := http.NewRequest("POST", "https://api.whoisfreaks.com/v1.0/geolocation?apiKey=API_KEY", payload)
	req.Header.Set("Content-Type", "application/json")
	client := &http.Client{}
	resp, _ := client.Do(req)
	defer resp.Body.Close()
	body, _ := ioutil.ReadAll(resp.Body)
	fmt.Println(string(body))
}