Python SDK for CKMT API - A security data search platform
Project description
CKMT SDK
A Python SDK for the CKMT API
Installation
pip install ckmt-python
Or install from source:
git clone https://github.com/projektckmt/ckmt-python.git
cd ckmt-python
pip install -e .
Quick Start
from ckmt import CKMT
# Initialize the client
client = CKMT(api_key="your_api_key_here")
# Get host information
host = client.host("8.8.8.8")
print(host)
# Search for hosts
results = client.search("nginx", page=1, size=10)
for match in results['matches']:
print(match['ip'])
# Get statistics
stats = client.stats()
print(f"Total hosts: {stats['total_hosts']}")
# Count results
count = client.count(port="443")
print(f"Hosts with port 443: {count['count']}")
# Get facets
facets = client.facets("apache", facets="country,port,service")
print(facets)
Async Support
import asyncio
from ckmt import AsyncCKMT
async def main():
client = AsyncCKMT(api_key="your_api_key_here")
# Search asynchronously
results = await client.search("nginx")
print(results)
# Get host info
host = await client.host("8.8.8.8")
print(host)
asyncio.run(main())
Features
Search API
search()- Search for hosts using various filtershost()- Get all data for a specific IPcount()- Count hosts matching filtersfacets()- Get aggregated statisticsports()- Get list of portsservices()- Get list of servicesstats()- Get overall platform statistics
API Methods
Search Methods
search(query, **kwargs)
Search for hosts using various filters.
Parameters:
query(str, optional): Search queryport(int, optional): Filter by portservice(str, optional): Filter by serviceproduct(str, optional): Filter by productversion(str, optional): Filter by versioncountry(str, optional): Filter by country codeasn(str, optional): Filter by ASNos(str, optional): Filter by OSvuln(str, optional): Filter by vulnerability/CVEhttp_title(str, optional): Filter by HTTP titlehttp_status(int, optional): Filter by HTTP statustechnology(str, optional): Filter by technologypage(int): Page number (default: 1)size(int): Results per page (default: 10)
host(ip)
Get all data for a specific IP address.
Parameters:
ip(str): IP address to lookup
count(query=None, port=None, country=None)
Count hosts matching filters.
Parameters:
query(str, optional): Search queryport(str, optional): Port numbercountry(str, optional): Country code
facets(query=None, facets="country,port,service,technology")
Get aggregated statistics.
Parameters:
query(str, optional): Search queryfacets(str): Comma-separated facets to return
Error Handling
from ckmt import CKMT, CKMTError
client = CKMT(api_key="your_key")
try:
results = client.search("test")
except CKMTError as e:
print(f"API Error: {e}")
Configuration
You can configure the SDK using environment variables:
export CKMT_API_KEY="your_api_key"
export CKMT_BASE_URL="https://api.ckmt.io" # Optional, defaults to https://api.ckmt.io
Then initialize without parameters:
from ckmt import CKMT
client = CKMT() # Uses environment variables
License
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 Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ckmt_python-1.0.0-py3-none-any.whl.
File metadata
- Download URL: ckmt_python-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e721995ee3c04219667a36fa5753808d8b6518771015b2b3343d0abd1e68683
|
|
| MD5 |
0efeb8a01604551c1dd29b7519301da4
|
|
| BLAKE2b-256 |
4e8923c1d1edb9e6e077f5a53160790eaada0336c34043a9d3c0bf71ee490371
|