API - Integration
Convert IP
This http method allows you to convert a single IP address into its corresponding geolocation data.
GET
/
convert
Ip2Geo - Convert IP
curl --request GET \
--url https://api.ip2geo.dev/convert \
--header 'x-api-key: <api-key>'import requests
url = "https://api.ip2geo.dev/convert"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.ip2geo.dev/convert', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ip2geo.dev/convert",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.ip2geo.dev/convert"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.ip2geo.dev/convert")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ip2geo.dev/convert")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>",
"code": 123,
"_req": {
"reqId": "<string>",
"resTime": 123
},
"data": {
"ip": "<string>",
"type": "ipv4",
"is_eu": true,
"continent": {
"name": "<string>",
"code": "<string>",
"geoname_id": 123,
"country": {
"name": "<string>",
"code": "<string>",
"geoname_id": 123,
"phone_code": "<string>",
"capital": "<string>",
"tld": "<string>",
"subdivision": {
"name": "<string>",
"code": "<string>"
},
"city": {
"name": "<string>",
"geoname_id": 123,
"latitude": 123,
"longitude": 123,
"accuracy_radius": 123,
"metro_code": 123,
"postal_code": "<string>",
"timezone": {
"name": "<string>",
"time_now": "<string>"
}
},
"flag": {
"img": "<string>",
"emoji": "<string>",
"emoji_unicode": "<string>"
},
"currency": {
"name": "<string>",
"code": "<string>",
"symbol": "<string>"
}
}
},
"registered_country": {
"name": "<string>",
"code": "<string>",
"geoname_id": 123
},
"asn": {
"number": 123,
"name": "<string>"
},
"completion_time": {
"miliseconds": 123,
"seconds": 123
}
}
}{
"success": false,
"message": "<string>",
"code": 123,
"_req": {
"reqId": "<string>",
"resTime": 123
},
"data": {}
}{
"success": false,
"message": "<string>",
"code": 123,
"_req": {
"reqId": "<string>",
"resTime": 123
},
"data": {}
}{
"success": false,
"message": "<string>",
"code": 123,
"_req": {
"reqId": "<string>",
"resTime": 123
},
"data": {}
}{
"success": false,
"message": "<string>",
"code": 123,
"_req": {
"reqId": "<string>",
"resTime": 123
},
"data": {}
}Authorizations
Use your Ip2Geo secret key (i2g_sk_...) for server-side requests, or public key (i2g_pk_...) for client-side requests. Example: x-api-key: i2g_sk_abc123.
Query Parameters
IPv4 or IPv6 address to lookup.
Was this page helpful?
⌘I
Ip2Geo - Convert IP
curl --request GET \
--url https://api.ip2geo.dev/convert \
--header 'x-api-key: <api-key>'import requests
url = "https://api.ip2geo.dev/convert"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.ip2geo.dev/convert', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ip2geo.dev/convert",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.ip2geo.dev/convert"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.ip2geo.dev/convert")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ip2geo.dev/convert")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>",
"code": 123,
"_req": {
"reqId": "<string>",
"resTime": 123
},
"data": {
"ip": "<string>",
"type": "ipv4",
"is_eu": true,
"continent": {
"name": "<string>",
"code": "<string>",
"geoname_id": 123,
"country": {
"name": "<string>",
"code": "<string>",
"geoname_id": 123,
"phone_code": "<string>",
"capital": "<string>",
"tld": "<string>",
"subdivision": {
"name": "<string>",
"code": "<string>"
},
"city": {
"name": "<string>",
"geoname_id": 123,
"latitude": 123,
"longitude": 123,
"accuracy_radius": 123,
"metro_code": 123,
"postal_code": "<string>",
"timezone": {
"name": "<string>",
"time_now": "<string>"
}
},
"flag": {
"img": "<string>",
"emoji": "<string>",
"emoji_unicode": "<string>"
},
"currency": {
"name": "<string>",
"code": "<string>",
"symbol": "<string>"
}
}
},
"registered_country": {
"name": "<string>",
"code": "<string>",
"geoname_id": 123
},
"asn": {
"number": 123,
"name": "<string>"
},
"completion_time": {
"miliseconds": 123,
"seconds": 123
}
}
}{
"success": false,
"message": "<string>",
"code": 123,
"_req": {
"reqId": "<string>",
"resTime": 123
},
"data": {}
}{
"success": false,
"message": "<string>",
"code": 123,
"_req": {
"reqId": "<string>",
"resTime": 123
},
"data": {}
}{
"success": false,
"message": "<string>",
"code": 123,
"_req": {
"reqId": "<string>",
"resTime": 123
},
"data": {}
}{
"success": false,
"message": "<string>",
"code": 123,
"_req": {
"reqId": "<string>",
"resTime": 123
},
"data": {}
}