Python wrapper for Greip API
Project description
Greip Python SDK
The Greip Python SDK allows you to easily interact with the Greip API for various functionalities, including IP geolocation, threat intelligence, email validation, and more.
Report Issue · Request Feature · Greip Website · Documentation
Installation
You can install the Greip SDK via pip. Run the following command:
pip install greip
Usage
To use the Greip SDK, you need to initialize a Greip object with your API token. Here’s a basic example:
import greip
# Initialize the Greip instance with your API token
greip_instance = greip.Greip("YOUR_API_TOKEN")
# Example: Lookup IP information
response = greip_instance.lookup("1.1.1.1")
print(response) # Access properties like response.ip, response.country, etc.
Methods
The Greip SDK provides various methods to interact with the API:
- lookup(ip, params=None, lang=“EN”): Get geolocation information about an IP address.
- threats(ip): Get information about threats related to an IP address.
- bulk_lookup(ips, params=None, lang=“EN”): Get geolocation information about multiple IP addresses.
- country(country_code, params=None, lang=“EN”): Get information about a country.
- profanity(text, params=None, lang=“EN”): Check if a text contains profanity.
- asn(asn): Get information about an ASN.
- email(email): Validate an email address.
- phone(phone, country_code): Validate/lookup a phone number.
- iban(iban): Validate/lookup an IBAN number.
- payment(data): Check if a payment transaction is fraudulent.
Example of Method Usage
# Lookup country information
country_info = greip_instance.country("US")
print(country_info) # Access properties like country_info.countryName, country_info.population, etc.
Development mode
If you need to test the integration without affecting your account subscription usage you can simple set the test_mode
attribute to True
when you initialize the Greip instance, here's an example:
greip_instance = greip.Greip("YOUR_API_TOKEN", test_mode=True)
[!WARNING] Enabling the development environment will lead to return fake information. Just make sure to not use it in production.
Error Handling
The SDK raises ValueError for invalid input parameters and requests.exceptions.RequestException for issues related to API requests. Ensure you handle exceptions properly in your code.
try:
response = greip_instance.lookup("INVALID_IP")
except ValueError as ve:
print(f"ValueError: {ve}")
except requests.exceptions.RequestException as re:
print(f"RequestException: {re}")
Contributing
Contributions are welcome! Please feel free to submit a pull request or open an issue for any improvements or bugs you encounter.
License
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
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 greip-1.0.1.tar.gz
.
File metadata
- Download URL: greip-1.0.1.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3688e479296526aaa8d6749580b546f6b053bd9c1a860f4e91848801687eb419 |
|
MD5 | e98083eb50afe2db4ecdaea2c1ab0921 |
|
BLAKE2b-256 | af331340eaaa286c6c3678972d53408a0d24ac5d023c988d962b69b6a00897f4 |
File details
Details for the file greip-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: greip-1.0.1-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d64e0f8d42494e8e4875ab04a34e806453b426e779c2db7e0936da6fb8ed2a44 |
|
MD5 | 2460ed77b114b2af24266e167b417d85 |
|
BLAKE2b-256 | 133f1a5f50e8056d0c45bc64ed31be50a48a7cc8e3d47cc4e1657dee413be0a9 |