Client library for CSP Lookup API.
Project description
csplookup
Client library for CSP Lookup API.
Install
pip install csplookup
Usage
from csplookup import CSPClient
from csplookup.errors import MaxLimitReached
client = CSPClient(api_key="YOUR_API_KEY")
res = client.lookup("4.2.2.4")
# check for api errors
try:
res.check_api_errors()
except MaxLimitReached:
print("max limit reached")
except Exception as err:
print("other errors")
# NOTE: check errors file for more exceptions
# get json data:
json_data = res.get_json()
print(json_data)
# country code:
print(json_data["Result"]["Country"]["IsoCode"])
# or
print(res.get_country_code())
Methods
Some helper methods that can help you get the data you need faster:
# get country iso code
print(res.get_country_code())
# get country name (in english):
print(res.get_country_en_name())
# get city name (in english):
print(res.get_city_en_name())
License
MIT
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
csplookup-1.4.tar.gz
(2.9 kB
view details)
File details
Details for the file csplookup-1.4.tar.gz
.
File metadata
- Download URL: csplookup-1.4.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cce0590c59003d3ecc3acfb0ed3e430befe2e70823bae91722aea441aebb0234 |
|
MD5 | 20e99b403516202106cd8d852cf6d947 |
|
BLAKE2b-256 | 622a349893d4c58cb05a69a6f317b981018f3670bdfff7847a604d6c74ea88a2 |