curl https://api.ipclues.com/v1/lookup/ip/1.1.1.1
package main
import (
"encoding/json"
"fmt"
"net/http"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.ipclues.com/v1/lookup/ip/1.1.1.1", nil)
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
var data map[string]interface{}
json.NewDecoder(res.Body).Decode(&data)
fmt.Println(data["country_code"]) // "AU"
fmt.Println(data["country_name"]) // "Australia"
}
const res = await fetch("https://api.ipclues.com/v1/lookup/ip/1.1.1.1");
const data = await res.json();
console.log(data.country_code); // "AU"
console.log(data.country_name); // "Australia"
<?php
$ch = curl_init("https://api.ipclues.com/v1/lookup/ip/1.1.1.1");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
echo $data["country_code"]."\n"; // "AU"
echo $data["country_name"]."\n"; // "Australia"
import requests
res = requests.get("https://api.ipclues.com/v1/lookup/ip/1.1.1.1")
data = res.json()
print(data["country_code"]) # "AU"
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let res = client
.get("https://api.ipclues.com/v1/lookup/ip/1.1.1.1")
.send()
.await?;
let data: serde_json::Value = res.json().await?;
println!("{}", data["country_code"]); // "AU"
println!("{}", data["country_name"]); // "Australia"
Ok(())
}