Skip to main content

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 filters
  • host() - Get all data for a specific IP
  • count() - Count hosts matching filters
  • facets() - Get aggregated statistics
  • ports() - Get list of ports
  • services() - Get list of services
  • stats() - Get overall platform statistics

API Methods

Search Methods

search(query, **kwargs)

Search for hosts using various filters.

Parameters:

  • query (str, optional): Search query
  • port (int, optional): Filter by port
  • service (str, optional): Filter by service
  • product (str, optional): Filter by product
  • version (str, optional): Filter by version
  • country (str, optional): Filter by country code
  • asn (str, optional): Filter by ASN
  • os (str, optional): Filter by OS
  • vuln (str, optional): Filter by vulnerability/CVE
  • http_title (str, optional): Filter by HTTP title
  • http_status (int, optional): Filter by HTTP status
  • technology (str, optional): Filter by technology
  • page (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 query
  • port (str, optional): Port number
  • country (str, optional): Country code

facets(query=None, facets="country,port,service,technology")

Get aggregated statistics.

Parameters:

  • query (str, optional): Search query
  • facets (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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ckmt_python-1.0.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

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

Hashes for ckmt_python-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2e721995ee3c04219667a36fa5753808d8b6518771015b2b3343d0abd1e68683
MD5 0efeb8a01604551c1dd29b7519301da4
BLAKE2b-256 4e8923c1d1edb9e6e077f5a53160790eaada0336c34043a9d3c0bf71ee490371

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page