Kotlin guide
Use FindIP with Kotlin
Use Kotlin/JVM to request IP geolocation and read the FindIP intelligence model from the same response.
Endpoint
Authenticated IP lookup
GET https://api.findip.net/{ip}/?token={token}
JSON parserThe sample uses
org.json for a compact, readable example.Decision fieldsStart with
verdict, risk, and flags.Response guideView the full response model
Kotlin example
Simple JVM example with HTTP status handling.
import java.net.HttpURLConnection
import java.net.URI
import java.net.URLEncoder
import java.nio.charset.StandardCharsets
import org.json.JSONObject
fun main() {
val ip = "8.8.8.8"
val token = "YOUR_API_KEY"
val encodedToken = URLEncoder.encode(token, StandardCharsets.UTF_8)
val uri = URI("https://api.findip.net/$ip/?token=$encodedToken&returnIp=true").toURL()
val connection = uri.openConnection() as HttpURLConnection
connection.requestMethod = "GET"
connection.setRequestProperty("Accept", "application/json")
connection.connectTimeout = 5000
connection.readTimeout = 10000
if (connection.responseCode !in 200..299) {
error("FindIP request failed: ${connection.responseCode}")
}
val data = JSONObject(connection.inputStream.bufferedReader().use { it.readText() })
val intelligence = data.getJSONObject("intelligence")
println("City: ${data.getJSONObject("city").getJSONObject("names").optString("en")}")
println("Country: ${data.getJSONObject("country").getJSONObject("names").optString("en")}")
println("ISP: ${data.getJSONObject("traits").optString("isp")}")
println("ASN: ${data.getJSONObject("traits").optInt("autonomous_system_number")}")
println("Verdict: ${intelligence.getJSONObject("summary").getString("verdict")}")
println("Risk: ${intelligence.getJSONObject("risk").getInt("score")} ${intelligence.getJSONObject("risk").getString("level")}")
println("VPN: ${intelligence.getJSONObject("flags").getBoolean("is_vpn")}")
println("Proxy: ${intelligence.getJSONObject("flags").getBoolean("is_proxy")}")
println("Tor: ${intelligence.getJSONObject("flags").getBoolean("is_tor")}")
}