This Flutter package provides a convenient way to interact with the Greip API. It allows you to easily integrate Greip's fraud prevention & IP geolocation services into your application, and performing actions like IP Lookup, Email Validation, Phone Number Validation, ASN Lookup, BIN Lookup, and much more.
Report Issue · Request Feature · Greip Website · Documentation
To use the package in your Flutter project, just add it as a dependency in your pubspec.yaml
file as follows:
dependencies:
greip: ^1.1.0
Then, run the following command to install the package:
flutter pub get
Here's how you can use the Greip SDK in your Flutter project:
import 'package:greip/greip.dart';
Greip greip = Greip();
Before making any API requests, you need to set your API token (API Key) using the setToken
method:
greip.setToken('your-greip-token');
Replace your-greip-token
with your actual Greip API key.
That's it 🥳, now you're ready to start using the package methods.
Use this method to retrieve the IP address of the visitor/user with its full information.
import 'package:greip/src/enums/mode.dart';
import 'package:greip/src/enums/param.dart';
import 'package:greip/src/enums/language.dart';
try {
Map<String, dynamic> result = await greip.geoIp(params: [
Param.security,
Param.currency,
Param.timezone,
Param.location,
], lang: Language.en, mode: Mode.live);
print(result);
} catch (e) {
print('Error: $e');
}
Use this method to retrieve the information of a given IP address.
import 'package:greip/src/enums/mode.dart';
import 'package:greip/src/enums/param.dart';
import 'package:greip/src/enums/language.dart';
try {
Map<String, dynamic> result = await greip.ipLookup('1.1.1.1', params: [
Param.security,
Param.currency,
Param.timezone,
Param.location,
], lang: Language.en, mode: Mode.live);
print(result);
} catch (e) {
print('Error: $e');
}
This method can be used without having an account/API-key in Greip. Please feel free to use it if you want to get ONLY the IP Address of your visitors/users.
try {
Map<String, dynamic> result = await greip.ip();
print(result);
} catch (e) {
print('Error: $e');
}
You can use this method to retrieve the information of multiple IP addresses (no need to use the ipLookup
emthod inside a loop).
import 'package:greip/src/enums/mode.dart';
import 'package:greip/src/enums/param.dart';
import 'package:greip/src/enums/language.dart';
try {
List<String> ips = ['1.1.1.1', '2.2.2.2'];
Map<String, dynamic> result = await greip.bulkLookup(ips, params: [
Param.security,
Param.currency,
Param.timezone,
Param.location,
], lang: Language.en, mode: Mode.live);
print(result);
} catch (e) {
print('Error: $e');
}
In this method, Greip will help you lookup any given AS Number and returning all data related to it, like: name, org (the organization name), country, domain, email, phone, totalIPs, list of all routes (v4 & v6) related the given AS Number, etc.
import 'package:greip/src/enums/mode.dart';
try {
Map<String, dynamic> result = await greip.asnLookup('AS01', mode: Mode.live);
print(result);
} catch (e) {
print('Error: $e');
}
This method can be used to detect abuse of your website/app. It’s a great way to know more about your user inputs and whether they contain profanity (bad words) or not before releasing them to the public.
import 'package:greip/src/enums/mode.dart';
try {
Map<String, dynamic> result = await greip.profanity('This is just a text with no profanity.', mode: Mode.live);
print(result);
} catch (e) {
print('Error: $e');
}
This method can help you retrieve information of the given country.
import 'package:greip/src/enums/mode.dart';
import 'package:greip/src/enums/language.dart';
try {
Map<String, dynamic> result = await greip.countryLookup('SA', lang: Language.en, mode: Mode.live);
print(result);
} catch (e) {
print('Error: $e');
}
This method provides an additional layer of validation for your system. While validating email syntax is important, it is not sufficient.
This method goes beyond syntax validation by checking the domain’s validity, the availability of the Mail Service, detecting Disposable Email (Temporary Emails), etc. By utilising this method, you can ensure a more thorough validation process for email addresses.
import 'package:greip/src/enums/mode.dart';
try {
Map<String, dynamic> result = await greip.validateEmail('[email protected]', mode: Mode.live);
print(result);
} catch (e) {
print('Error: $e');
}
This method can be used as an extra-layer of your system for validating phone numbers. It validates phone number syntax and valid-possibility.
import 'package:greip/src/enums/mode.dart';
try {
Map<String, dynamic> result = await greip.validatePhone('01234567890', 'TR', mode: Mode.live);
print(result);
} catch (e) {
print('Error: $e');
}
Prevent financial losses by deploying AI-Powered modules.
import 'package:greip/src/enums/mode.dart';
try {
Map<String, dynamic> data = {
action: 'purchase',
website_domain: 'greip.io',
website_name: 'Greip',
merchant_id: 12,
shipment_id: 123,
transaction_id: 1234,
transaction_amount: 1000,
transaction_currency: 'GBP',
cart_items: {
item_id: 1,
item_name: 'Product name',
item_quantity: 1,
item_price: '1100.55',
item_category_id: 1,
},
isDigitalProducts: true,
coupon: 'ASDF',
customer_id: 1,
customer_firstname: 'Firstname',
customer_lastname: 'Lastname',
customer_pob: 'London',
customer_ip: '1.1.1.1',
customer_country: 'GB',
customer_region: 'Greater London',
customer_city: 'London',
customer_zip: 'NW10 7PQ',
customer_street: '7 Coronation Road',
customer_street2: '',
customer_latitude: 0.123,
customer_longitude: 0.123,
customer_device_id: 'UNIQUE_DEVICE_ID',
customer_phone: '000000000',
customer_registration_date: 1677554670,
customer_balance: '1000.00',
customer_dob: '1997-19-05',
customer_email: '[email protected]',
customer_2fa: true,
customer_useragent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
shipping_country: 'GB',
shipping_region: 'London',
shipping_city: 'London',
shipping_zip: 'NW10 7PQ',
shipping_street: '7 Coronation Road',
shipping_street2: '',
shipping_latitude: 0.123,
shipping_longitude: 0.123,
billing_country: 'GB',
billing_region: 'Greater London',
billing_city: 'London',
billing_zip: 'NW10 7PQ',
billing_street: '7 Coronation Road',
billing_street2: '',
billing_latitude: 0.123,
billing_longitude: 0.123,
payment_type: 'applepay',
card_name: 'Firstname Lastname',
card_number: '1234XXXXXXXX1234',
card_expiry: '29/05',
cvv_result: true,
};
Map<String, dynamic> result = await greip.paymentFraud(data, mode: Mode.live);
print(result);
} catch (e) {
print('Error: $e');
}
This method allows you to validate International Bank Account Numbers (IBANs) and retrieve additional information about the country associated with the IBAN.
import 'package:greip/src/enums/mode.dart';
try {
Map<String, dynamic> result = await greip.validateIban('DE89370400440532013000', mode: Mode.live);
print(result);
} catch (e) {
print('Error: $e');
}
You can find the full guide of this package by visiting our documentation page.
Contributions are welcome! If you encounter any issues or have suggestions for improvements, feel free to open an issue or create a pull request.