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
Metadata
Release files for csplookup 1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| csplookup-1.4.tar.gz | 2.9 kB | Details |
Release files / csplookup-1.4.tar.gz
| Download URL | csplookup-1.4.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cce0590c59003d3ecc3acfb0ed3e430befe2e70823bae91722aea441aebb0234
|
|
BLAKE2b-256 checksum How to use checksums |
622a349893d4c58cb05a69a6f317b981018f3670bdfff7847a604d6c74ea88a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|