Skip to content

Commit d74ca60

Browse files
authored
Update README.md
1 parent 8de919c commit d74ca60

File tree

1 file changed

+2
-225
lines changed

1 file changed

+2
-225
lines changed

README.md

Lines changed: 2 additions & 225 deletions
Original file line numberDiff line numberDiff line change
@@ -24,228 +24,5 @@ As an alternative, this module can also call the IP2Location Web Service. This r
2424

2525
https://www.ip2location.com/web-service/ip2location
2626

27-
## Installation
28-
29-
To install this module type the following:
30-
31-
```bash
32-
33-
npm install ip2location-nodejs
34-
35-
```
36-
37-
## QUERY USING THE BIN FILE
38-
39-
## Dependencies
40-
41-
This library requires IP2Location BIN data file to function. You may download the BIN data file at
42-
* IP2Location LITE BIN Data (Free): https://lite.ip2location.com
43-
* IP2Location Commercial BIN Data (Comprehensive): https://www.ip2location.com
44-
45-
46-
## IPv4 BIN vs IPv6 BIN
47-
48-
Use the IPv4 BIN file if you just need to query IPv4 addresses.
49-
If you query an IPv6 address using the IPv4 BIN, you'll see the IPV6_NOT_SUPPORTED error.
50-
51-
Use the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses.
52-
53-
54-
## Methods
55-
56-
Below are the methods supported in this module.
57-
58-
|Method Name|Description|
59-
|---|---|
60-
|open|Opens the IP2Location BIN data for lookup.|
61-
|getAll|Returns the geolocation information in an object.|
62-
|getCountryShort|Returns the country code.|
63-
|getCountryLong|Returns the country name.|
64-
|getRegion|Returns the region name.|
65-
|getCity|Returns the city name.|
66-
|getISP|Returns the ISP name.|
67-
|getLatitude|Returns the latitude.|
68-
|getLongitude|Returns the longitude.|
69-
|getDomain|Returns the domain name.|
70-
|getZIPCode|Returns the ZIP code.|
71-
|getTimeZone|Returns the time zone.|
72-
|getNetSpeed|Returns the net speed.|
73-
|getIDDCode|Returns the IDD code.|
74-
|getAreaCode|Returns the area code.|
75-
|getWeatherStationCode|Returns the weather station code.|
76-
|getWeatherStationName|Returns the weather station name.|
77-
|getMCC|Returns the mobile country code.|
78-
|getMNC|Returns the mobile network code.|
79-
|getMobileBrand|Returns the mobile brand.|
80-
|getElevation|Returns the elevation in meters.|
81-
|getUsageType|Returns the usage type.|
82-
|getAddressType|Returns the address type.|
83-
|getCategory|Returns the IAB category.|
84-
|getDistrict|Returns the district name.|
85-
|getASN|Returns the autonomous system number (ASN).|
86-
|getAS|Returns the autonomous system (AS).|
87-
|close|Closes BIN file and resets metadata.|
88-
89-
90-
## Usage
91-
92-
```javascript
93-
94-
const {IP2Location} = require("ip2location-nodejs");
95-
96-
let ip2location = new IP2Location();
97-
98-
ip2location.open("./DB26.BIN");
99-
100-
testip = ['8.8.8.8', '2404:6800:4001:c01::67'];
101-
102-
for (var x = 0; x < testip.length; x++) {
103-
result = ip2location.getAll(testip[x]);
104-
for (var key in result) {
105-
console.log(key + ": " + result[key]);
106-
}
107-
console.log("--------------------------------------------------------------");
108-
}
109-
110-
ip2location.close();
111-
112-
```
113-
114-
## QUERY USING THE IP2LOCATION WEB SERVICE
115-
116-
## Methods
117-
Below are the methods supported in this module.
118-
119-
|Method Name|Description|
120-
|---|---|
121-
|open| 3 input parameters:<ol><li>IP2Location API Key.</li><li>Package (WS1 - WS25)</li></li><li>Use HTTPS or HTTP</li></ol> |
122-
|lookup|Query IP address. This method returns an object containing the geolocation info. <ul><li>country_code</li><li>country_name</li><li>region_name</li><li>city_name</li><li>latitude</li><li>longitude</li><li>zip_code</li><li>time_zone</li><li>isp</li><li>domain</li><li>net_speed</li><li>idd_code</li><li>area_code</li><li>weather_station_code</li><li>weather_station_name</li><li>mcc</li><li>mnc</li><li>mobile_brand</li><li>elevation</li><li>usage_type</li><li>address_type</li><li>category</li><li>continent<ul><li>name</li><li>code</li><li>hemisphere</li><li>translations</li></ul></li><li>country<ul><li>name</li><li>alpha3_code</li><li>numeric_code</li><li>demonym</li><li>flag</li><li>capital</li><li>total_area</li><li>population</li><li>currency<ul><li>code</li><li>name</li><li>symbol</li></ul></li><li>language<ul><li>code</li><li>name</li></ul></li><li>idd_code</li><li>tld</li><li>translations</li></ul></li><li>region<ul><li>name</li><li>code</li><li>translations</li></ul></li><li>city<ul><li>name</li><li>translations</li></ul></li><li>geotargeting<ul><li>metro</li></ul></li><li>country_groupings</li><li>time_zone_info<ul><li>olson</li><li>current_time</li><li>gmt_offset</li><li>is_dst</li><li>sunrise</li><li>sunset</li></ul></li><ul>|
123-
|getCredit()|This method returns the web service credit balance in an object.|
124-
125-
## Usage
126-
127-
```javascript
128-
129-
const {IP2LocationWebService} = require("ip2location-nodejs");
130-
131-
let ws = new IP2LocationWebService();
132-
133-
let ip = "8.8.8.8";
134-
let apiKey = "YOUR_API_KEY";
135-
let apiPackage = "WS25";
136-
let useSSL = true;
137-
138-
// addon and lang to get more data and translation (leave both blank if you don't need them)
139-
let addon = "continent,country,region,city,geotargeting,country_groupings,time_zone_info";
140-
let lang = "fr";
141-
142-
ws.open(apiKey, apiPackage, useSSL);
143-
144-
ws.lookup(ip, addon, lang, (err, data) => {
145-
if (!err) {
146-
console.log(data);
147-
148-
ws.getCredit((err, data) => {
149-
if (!err) {
150-
console.log(data);
151-
}
152-
});
153-
}
154-
});
155-
156-
```
157-
158-
## IPTOOLS CLASS
159-
160-
## Methods
161-
Below are the methods supported in this module.
162-
163-
|Method Name|Description|
164-
|---|---|
165-
|isIPV4(myIP)|Returns true if string contains an IPv4 address. Otherwise false.|
166-
|isIPV6(myIP)|Returns true if string contains an IPv6 address. Otherwise false.|
167-
|ipV4ToDecimal(myIP)|Returns the IP number for an IPv4 address.|
168-
|ipV6ToDecimal(myIP)|Returns the IP number for an IPv6 address.|
169-
|decimalToIPV4(ipNum)|Returns the IPv4 address for the supplied IP number.|
170-
|decimalToIPV6(ipNum)|Returns the IPv6 address for the supplied IP number.|
171-
|compressIPV6(myIP)|Returns the IPv6 address in compressed form.|
172-
|expandIPV6(myIP)|Returns the IPv6 address in expanded form.|
173-
|ipV4ToCIDR(ipFrom, ipTo)|Returns a list of CIDR from the supplied IPv4 range.|
174-
|ipV6ToCIDR(ipFrom, ipTo)|Returns a list of CIDR from the supplied IPv6 range.|
175-
|cidrToIPV4(cidr)|Returns the IPv4 range from the supplied CIDR.|
176-
|cidrToIPV6(cidr)|Returns the IPv6 range from the supplied CIDR.|
177-
178-
## Usage
179-
180-
```javascript
181-
const {IPTools} = require("ip2location-nodejs");
182-
183-
let tools = new IPTools();
184-
185-
console.log(tools.isIPV4("60.54.166.38"));
186-
console.log(tools.isIPV6("2001:4860:4860::8888"));
187-
console.log(tools.ipV4ToDecimal("60.54.166.38"));
188-
console.log(tools.ipV6ToDecimal("2001:4860:4860::8888"));
189-
console.log(tools.decimalToIPV4(1010214438));
190-
console.log(tools.decimalToIPV6("530610913025797008819807084026527744"));
191-
console.log(tools.compressIPV6("66:3123:4860:3234:411:23:000:000"));
192-
console.log(tools.expandIPV6("66:023:40:34:411:23:000:000"));
193-
let cidr = tools.ipV4ToCIDR("10.0.0.0", "10.10.2.255");
194-
for (const x of cidr) {
195-
console.log(x);
196-
}
197-
cidr = tools.ipV6ToCIDR("2001:4860:4860:0000:0000:0000:0000:8888", "2001:4860:4860:0000:eeee:ffff:ffff:ffff");
198-
for (const x of cidr) {
199-
console.log(x);
200-
}
201-
console.log(tools.cidrToIPV4("10.123.80.0/12"));
202-
console.log(tools.cidrToIPV6("2002:1234::abcd:ffff:c0a8:101/62"));
203-
```
204-
205-
## COUNTRY CLASS
206-
207-
## Methods
208-
Below are the methods supported in this module.
209-
210-
|Method Name|Description|
211-
|---|---|
212-
|Constructor(csvFile)|Expect a IP2Location Country Information CSV file. This database is free for download at https://www.ip2location.com/free/country-information|
213-
|getCountryInfo(countryCode)|Returns the country information.|
214-
215-
## Usage
216-
217-
```javascript
218-
const {Country} = require("ip2location-nodejs");
219-
220-
let country = new Country("./IP2LOCATION-COUNTRY-INFORMATION-BASIC.CSV");
221-
222-
country.getCountryInfo("US").then(country_info => {
223-
console.log(country_info);
224-
});
225-
226-
country.getCountryInfo("").then(country_info => {
227-
console.log(country_info);
228-
});
229-
```
230-
231-
## REGION CLASS
232-
233-
## Methods
234-
Below are the methods supported in this module.
235-
236-
|Method Name|Description|
237-
|---|---|
238-
|Constructor(csvFile)|Expect a IP2Location ISO 3166-2 Subdivision Code CSV file. This database is free for download at https://www.ip2location.com/free/iso3166-2|
239-
|getRegionCode(countryCode, regionName)|Returns the region code for the supplied country code and region name.|
240-
241-
## Usage
242-
243-
```javascript
244-
const {Region} = require("ip2location-nodejs");
245-
246-
let region = new Region("./IP2LOCATION-ISO3166-2.CSV");
247-
248-
region.getRegionCode("US", "California").then(region_code => {
249-
console.log(region_code);
250-
});
251-
```
27+
## Developer Documentation
28+
To learn more about installation, usage, and code examples, please visit the developer documentation at [https://ip2location-nodejs.readthedocs.io/en/latest/index.html.](https://ip2location-nodejs.readthedocs.io/en/latest/index.html)

0 commit comments

Comments
 (0)