Easily fetch IP address data from SeeIP
- Requirements:
- Dart 2.1.4+
- Download:
- Dart packages
- GitHub
Overview
SeeIP Client is a wrapper for the SeeIP API, written in Dart. It makes it easy to obtain your public IP address and other related information. This can tell you how your device is identified on websites you visit, or if your VPN is working as expected.
SeeIP Client fetches your public IP address related information using the seeip.org API. Geo IP information can also be fetched, showing you things like the name and location of your Internet Service Provider (ISP).
Examples
Only IP address
Fetch only the IP address of the requesting device.
SeeipClient seeip = SeeipClient();
OnlyIP ip = await seeip.getIP();
print(ip);
OnlyIP {ip: 12.345.67.89}
Geo IP address
Fetch the Geo IP information for the requesting device.
SeeipClient seeip = SeeipClient();
GeoIP geoIP = await seeip.getGeoIP();
print(geoIP);
GeoIP {ip: 12.345.67.89,
organization: AS98765 My ISP,
city: London,
region: Greater London,
dma_code: 0,
area_code: 0,
timezone: Europe/London,
offset: 1,
longitude: -0.1224,
country_code3: GBR,
postal_code: WC1,
continent_code: EU,
country: United Kingdom,
region_code: null,
country_code: GB,
latitude: 51.4964}
Specific Geo IP address
Fetch the Geo IP information for a specific IP address.
SeeipClient seeip = SeeipClient();
GeoIP geoIP = await seeip.getGeoIP('216.58.208.174');
print(geoIP);
GeoIP {ip: 216.58.208.174,
organization: AS15169 Google Inc.,
city: Mountain View,
region: California,
dma_code: 0,
area_code: 0,
timezone: America/Los_Angeles,
offset: -7,
longitude: -122.0574,
country_code3: USA,
postal_code: 94043,
continent_code: NA,
country: United States,
region_code: CA,
country_code: US,
latitude: 37.4192}
Only IPv4 address
Fetch only the IPv4 address of the requesting device.
SeeipClient seeip = SeeipClient();
OnlyIP ipv4 = await seeip.getIPv4();
print(ipv4);
OnlyIP {ip: 12.345.67.89}
Request with error handling
If the response status code from seeip.org is 429 (Too many requests) then the request will be automatically retried.
However, if the response is anything other than 429 or 200 (OK), then an error will be raised. It is recommended that your code catch this potential error.
SeeipClient seeip = SeeipClient();
GeoIP geoIP;
try {
geoIP = await seeip.getGeoIP();
} catch (e) {
// handle the error
}
Licence
SeeIP client by mad about brighton is licensed under a 3-Clause BSD License. Permissions beyond the scope of this licence may be available by contacting me.