iplocation.local
1.0.0
A quick package to perform IP geolocation lookups using ip2location.com databases.
Install-Package iplocation.local -Version 1.0.0
dotnet add package iplocation.local --version 1.0.0
<PackageReference Include="iplocation.local" Version="1.0.0" />
paket add iplocation.local --version 1.0.0
#r "nuget: iplocation.local, 1.0.0"
iplocation
This is a small and fast library that will import a geolocation database from IP2LOCATION into sqlite and provide a quick package to lookup IP address locations.
Installation
Usage
You need to register at ip2location.com and download one of the databases they provide. This code is made to parse the CSV version of the ip2location-lite-db5 database. This database will provide accuracy up to the city level, as well as latitude and longitude.
Once you have the ip2location-lite-db5.csv file on your computer, run this code to import it into a sqlite DB that will be used later for querying:
IpLocation.ImportIpLocationCsv(ipLocationCsv, ipLocationDb);
It will take a minute, it's processing around 3M records. You only need to do this once. It will generate a sqlite file with the parsed contents of the CSV file.
To query an IP address:
using (var ipl = new IpLocation(ipLocationDb))
{
var result = ipl.GetIpLocation("8.8.8.8");
Console.WriteLine(result);
}
You can check the "example" project for a full example.
iplocation
This is a small and fast library that will import a geolocation database from IP2LOCATION into sqlite and provide a quick package to lookup IP address locations.
Installation
Usage
You need to register at ip2location.com and download one of the databases they provide. This code is made to parse the CSV version of the ip2location-lite-db5 database. This database will provide accuracy up to the city level, as well as latitude and longitude.
Once you have the ip2location-lite-db5.csv file on your computer, run this code to import it into a sqlite DB that will be used later for querying:
IpLocation.ImportIpLocationCsv(ipLocationCsv, ipLocationDb);
It will take a minute, it's processing around 3M records. You only need to do this once. It will generate a sqlite file with the parsed contents of the CSV file.
To query an IP address:
using (var ipl = new IpLocation(ipLocationDb))
{
var result = ipl.GetIpLocation("8.8.8.8");
Console.WriteLine(result);
}
You can check the "example" project for a full example.
Dependencies
-
.NETStandard 2.0
- Microsoft.Data.Sqlite (>= 3.1.2)
Used By
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version History
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 164 | 3/12/2020 |