Section: API Solutions
IP geolocation lookup
2 endpoint(s). All requests require your API key — see Authentication.
GET /v1.0/geolocation
Get location, ASN, currency for an IP. 1 credit.
Parameters
| Parameter | In | Required | Type | Description |
|---|---|---|---|---|
ip |
query | yes | string |
Response (GeolocationResponse)
| Field | Type | Description |
|---|---|---|
ip |
string | |
location |
IpLocation | |
country_metadata |
CountryMetadata | |
network |
GeoNetwork | |
currency |
Currency |
IpLocation object
| Field | Type | Description |
|---|---|---|
continent_code |
string | |
continent_name |
string | |
country_code2 |
string | |
country_code3 |
string | |
country_name |
string | |
country_name_official |
string | |
country_capital |
string | |
state_prov |
string | |
state_code |
string | |
district |
string | |
city |
string | |
locality |
string | |
accuracy_radius |
string | |
confidence |
string | |
zipcode |
string | |
latitude |
string | |
longitude |
string | |
is_eu |
boolean | |
geoname_id |
string | |
country_emoji |
string |
CountryMetadata object
| Field | Type | Description |
|---|---|---|
calling_code |
string | |
tld |
string | |
languages |
array |
GeoNetwork object
| Field | Type | Description |
|---|---|---|
asn |
GeoAsn | |
connection_type |
string | |
company |
GeoCompany |
Currency object
| Field | Type | Description |
|---|---|---|
code |
string | |
name |
string | |
symbol |
string |
Usage
Python
"""Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation)."""
from whoisfreaks import Configuration, ApiClient
from whoisfreaks.api.geolocation_api import GeolocationApi
# Parameters for geolocation (GET /v1.0/geolocation):
# - ip (string, required)
config = Configuration()
config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once
api = GeolocationApi(ApiClient(config))
result = api.geolocation(ip="8.8.8.8")
print(result)TypeScript
// Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation)
// Parameters for geolocation (GET /v1.0/geolocation):
// - ip (string, required)
import { Configuration, GeolocationApi } from "whoisfreaks";
const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once
const api = new GeolocationApi(config);
async function main() {
const result = await api.geolocation({ ip: "8.8.8.8" });
console.log(result);
}
main().catch(console.error);Go
// Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation)
// Parameters for geolocation (GET /v1.0/geolocation):
// - ip (string, required)
package main
import (
"context"
"encoding/json"
"fmt"
wf "github.com/WhoisFreaks/whoisfreaks-go"
)
func main() {
cfg := wf.NewConfiguration()
client := wf.NewAPIClient(cfg)
// apiKey is set once via the request context
ctx := context.WithValue(context.Background(), wf.ContextAPIKeys,
map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}})
result, _, err := client.GeolocationAPI.Geolocation(ctx).Ip("8.8.8.8").Execute()
if err != nil { panic(err) }
b, _ := json.MarshalIndent(result, "", " ")
fmt.Println(string(b))
}POST /v1.0/geolocation
Up to 100 IPs.
Parameters
| Parameter | In | Required | Type | Description |
|---|
Response (GeolocationResponse)
| Field | Type | Description |
|---|---|---|
ip |
string | |
location |
IpLocation | |
country_metadata |
CountryMetadata | |
network |
GeoNetwork | |
currency |
Currency |
IpLocation object
| Field | Type | Description |
|---|---|---|
continent_code |
string | |
continent_name |
string | |
country_code2 |
string | |
country_code3 |
string | |
country_name |
string | |
country_name_official |
string | |
country_capital |
string | |
state_prov |
string | |
state_code |
string | |
district |
string | |
city |
string | |
locality |
string | |
accuracy_radius |
string | |
confidence |
string | |
zipcode |
string | |
latitude |
string | |
longitude |
string | |
is_eu |
boolean | |
geoname_id |
string | |
country_emoji |
string |
CountryMetadata object
| Field | Type | Description |
|---|---|---|
calling_code |
string | |
tld |
string | |
languages |
array |
GeoNetwork object
| Field | Type | Description |
|---|---|---|
asn |
GeoAsn | |
connection_type |
string | |
company |
GeoCompany |
Currency object
| Field | Type | Description |
|---|---|---|
code |
string | |
name |
string | |
symbol |
string |
Usage
Python
"""Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation)."""
from whoisfreaks import Configuration, ApiClient
from whoisfreaks.api.geolocation_api import GeolocationApi
from whoisfreaks.models.bulk_geolocation_request import BulkGeolocationRequest
# Parameters for bulkGeolocation (POST /v1.0/geolocation):
# - body: BulkGeolocationRequest (required) -- request body object
config = Configuration()
config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once
api = GeolocationApi(ApiClient(config))
bulk_geolocation_request = BulkGeolocationRequest() # populate fields as needed
result = api.bulk_geolocation(bulk_geolocation_request=bulk_geolocation_request)
print(result)TypeScript
// Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation)
// Parameters for bulkGeolocation (POST /v1.0/geolocation):
// - body: BulkGeolocationRequest (required) -- request body object
import { Configuration, GeolocationApi } from "whoisfreaks";
const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once
const api = new GeolocationApi(config);
async function main() {
const result = await api.bulkGeolocation({ bulkGeolocationRequest: {} });
console.log(result);
}
main().catch(console.error);Go
// Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation)
// Parameters for bulkGeolocation (POST /v1.0/geolocation):
// - body: BulkGeolocationRequest (required) -- request body object
package main
import (
"context"
"encoding/json"
"fmt"
wf "github.com/WhoisFreaks/whoisfreaks-go"
)
func main() {
cfg := wf.NewConfiguration()
client := wf.NewAPIClient(cfg)
// apiKey is set once via the request context
ctx := context.WithValue(context.Background(), wf.ContextAPIKeys,
map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}})
result, _, err := client.GeolocationAPI.BulkGeolocation(ctx).BulkGeolocationRequest(*wf.NewBulkGeolocationRequest()).Execute()
if err != nil { panic(err) }
b, _ := json.MarshalIndent(result, "", " ")
fmt.Println(string(b))
}