Skip to content

Commit

Permalink
BaseURL changed & IP Threats endpoint added
Browse files Browse the repository at this point in the history
  • Loading branch information
gre-dev committed Mar 14, 2024
1 parent 923c94b commit 77b69b1
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 13 deletions.
37 changes: 27 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The official Javascript package of Greip API
  
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/license/apache-2-0)
  
![API Status](https://img.shields.io/website?down_color=orange&down_message=down&label=API%20status&up_color=green&up_message=up&url=https%3A%2F%2Fgregeoip.com)
![API Status](https://img.shields.io/website?down_color=orange&down_message=down&label=API%20status&up_color=green&up_message=up&url=https%3A%2F%greipapi.com)

---

Expand Down Expand Up @@ -104,7 +104,24 @@ await GeoIP({
});
```
### 2. IP Lookup Method
### 2. IP Threats Method
Use this method to retrieve threat intelligence information associated with a given IP address.
```javascript
await Threats({
key: 'your-api-key',
ip: '1.1.1.1',
})
.then((res: any) => {
console.log(res.data); // Log Response
})
.catch((error: any) => {
console.log(error);
});
```
### 3. IP Lookup Method
Use this method to retrieve the information of a given IP address.
Expand All @@ -121,7 +138,7 @@ await Lookup({
});
```
### 3. Bulk IP Lookup Method
### 4. Bulk IP Lookup Method
You can use this method to retrieve the information of multiple IP addresses (no need to use the `Lookup` method inside a loop).
Expand All @@ -138,7 +155,7 @@ await BulkLookup({
});
```
### 4. ASN Lookup Method
### 5. ASN Lookup Method
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.
Expand All @@ -155,7 +172,7 @@ await ASN({
});
```
### 5. Profanity Detection Method
### 6. Profanity Detection Method
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.
Expand All @@ -172,7 +189,7 @@ await BadWord({
});
```
### 6. Country Lookup Method
### 7. Country Lookup Method
This method can help you retrieve information of the given country.
Expand All @@ -189,7 +206,7 @@ await Country({
});
```
### 7. Email Validation Method
### 8. Email Validation Method
This method provides an additional layer of validation for your system. While validating email syntax is important, it is not sufficient.
Expand All @@ -208,7 +225,7 @@ await EmailValidation({
});
```
### 8. Phone Validation Method
### 9. Phone Validation Method
This method can be used as an extra-layer of your system for validating phone numbers. It validates phone number syntax and valid-possibility.
Expand All @@ -226,7 +243,7 @@ await PhoneValidation({
});
```
### 9. Payment Fraud Prevention Method
### 10. Payment Fraud Prevention Method
Prevent financial losses by deploying AI-Powered modules.
Expand Down Expand Up @@ -303,7 +320,7 @@ await PaymentFraud({
});
```
### 10. IBAN Validation Method
### 11. IBAN Validation Method
This method allows you to validate International Bank Account Numbers (IBANs) and retrieve additional information about the country associated with the IBAN.
Expand Down
2 changes: 1 addition & 1 deletion greip.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "greip.js",
"version": "2.3.4",
"version": "2.4.0",
"description": "The official Javascript library of Greip.",
"author": {
"name": "Greip",
Expand Down
54 changes: 54 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,60 @@ export const Lookup = (options: Options) => {
});
};

export const Threats = (options: Options) => {
if (typeof options !== 'object') options = {};

if (!options.key || options.key.length < 1) {
throw new Error('You should pass the API Key.');
}

return new Promise((resolve, reject) => {
const ip1 = options.ip || '';
const format1 = options.format || 'JSON';
const mode1 = options.mode || 'live';

// Validate the ip variable
if (ip1.length < 7) {
reject(new Error('You should pass the `ip` parameter.'));
}

// Validate the format variable
if (!availableFormats.includes(format1)) {
reject(
new Error(
'The `format` option value "' +
format1 +
'" you specified is unknown.\nYou can use: `JSON`, `XML`, `CSV` or `Newline`.\nRead more at: https://docs.greip.io/api-reference/endpoint/ip-geolocation/ip-lookup',
),
);
}

// Validate the mode variable
if (mode1 !== 'live' && mode1 !== 'test') {
reject(
new Error(
'The `mode` option value "' +
mode1 +
'" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://docs.greip.io/api-reference/endpoint/ip-geolocation/ip-lookup',
),
);
}
makeHttpRquest(
'threats',
{
ip: ip1,
key: options.key,
format: format1,
mode: mode1,
},
(res: object) => {
if (typeof res !== 'object') res = JSON.parse(res);
resolve(res);
},
);
});
};

export const BulkLookup = (options: Options) => {
if (typeof options !== 'object') options = {};

Expand Down
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios';

export const baseURL = 'https://gregeoip.com/';
export const baseURL = 'https://greipapi.com/';
export const availableGeoIPParams = ['location', 'security', 'timezone', 'currency', 'device'];
export const availableLanguages = ['EN', 'AR', 'DE', 'FR', 'ES', 'JA', 'ZH', 'RU'];
export const availableFormats = ['JSON', 'XML', 'CSV', 'Newline'];
Expand Down

0 comments on commit 77b69b1

Please sign in to comment.