A Dart package that makes it easy to fetch data from SeeIP

Last modified: 21/04/2019 - 4 weeks, 1 day ago

Requirements: Dart 2.1.0+

Download: Dart packages | GitHub

A project tagged as: api, dart

Twitter Facebook Reddit

Overview

SeeIP Client fetches your public IP address related information using the seeip.org API.

It can be useful to otbtain your public IP address as it can tell you how your device is identified on websites you visit. This can confirm whether you are connected to the network you thought your were, or whether your VPN is working correctly.

Geo IP information can also be fetched, showing you things like the name and location of your Internet Service Provider (ISP).

SeeIP fetches this information by acting as a wrapper for the seeip.org API.

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 automaticllay 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.