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.0.tar.gz
.
File metadata
- Download URL: greip-1.0.0.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 | f8d1b0db05cc4ee68511de95cf002b804d77b0bf7cbd853158c2744f44d4f439 |
|
MD5 | bbe916138a5724452e0d4289724804e1 |
|
BLAKE2b-256 | 16894110f0b50e4c77358f91ca9eb73267a41c68002401ccf93e364d35397906 |
Provenance
File details
Details for the file greip-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: greip-1.0.0-py3-none-any.whl
- Upload date:
- Size: 13.6 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 | 1d61171a46df463de2db6d7712d0e62eeb1ee3b8c825582de65b3192e7566eeb |
|
MD5 | 87e909ded5013d4dd0e743ba487f3833 |
|
BLAKE2b-256 | a5fdad67c94b7470f311195e48b8cf2f2131b0a6ed148aad7e9138ea669e661e |