A better way to use IP2Location in Python
Project description
EasyI2L - Easy IP2Location Wrapper
easyi2l
is a Python wrapper around the IP2LOCATION library. It allows you to automatically download and load the IP2LOCATION database, simplifying the process of working with IP geolocation data.
Features
- Automatic Download: Fetches the IP2LOCATION database directly using your IP2LOCATION token.
- Database Loading: Automatically loads the downloaded database for immediate use.
- Simple API: Retrieve IP geolocation data with minimal setup.
Installation
Install the package via pip:
pip install easyi2l
Usage
Before using the package, ensure you have the IP2LOCATION_TOKEN
environment variable set. You can obtain a token from IP2Location LITE.
Example
Here's a simple example of how to use easyi2l
:
from easyi2l import EasyI2L, DBType
db = EasyI2L.download(DBType.DB11LITEBIN).load()
# Retrieve all data for an IP address
print(db.get_all("1.1.1.1"))
Environment Setup
You need to set the IP2LOCATION_TOKEN
environment variable for the package to function correctly. The package uses load_dotenv
from the dotenv
module to load this variable from a .env
file in your working directory.
Create a .env
file with the following content:
IP2LOCATION_TOKEN=your_token_here
Contributing
Feel free to open issues or submit pull requests to improve the library.
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file easyi2l-0.0.3.tar.gz
.
File metadata
- Download URL: easyi2l-0.0.3.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef9c24e9fcf3c4f97c108ba251c519b68ed2e2d839103f9ef45ddd52d120d24d |
|
MD5 | 7280b51962f280a29ffba8aa8f65a555 |
|
BLAKE2b-256 | 6eaa08fb18dde3385fcca4ad9a7e22ef087ec88c09977c87b29e7e626c7aecc6 |
File details
Details for the file easyi2l-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: easyi2l-0.0.3-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84c33d31aa6b3c67507d5672aecdc441dc3f1fa07d09e0e902236959119f6a48 |
|
MD5 | 7b446a828d6be231648ed69bc04fef63 |
|
BLAKE2b-256 | ced5d8bd678b3f5457281ccf555659091f2fe0b178afce20717ce7b98f77f13b |