SDKs overview

Threat Jammer offers Software Development Kits (SDKs) to facilitate integration with its various threat intelligence APIs, including IP Reputation, Domain Reputation, and ASN Reputation services. These SDKs abstract the underlying HTTP requests and response parsing, allowing developers to focus on integrating threat intelligence into their applications rather than managing API communication specifics. The primary goal of providing SDKs is to reduce development time and potential errors when building security automation, fraud prevention systems, or real-time threat detection mechanisms.

The official SDKs are designed to provide a consistent interface across supported programming languages, aligning with the structure and capabilities outlined in the Threat Jammer API reference documentation. By using an SDK, developers can often benefit from features like automatic authentication handling, request retries, and structured data models for API responses. This approach is common among API providers to improve developer experience, as noted by industry practices for API design best practices.

Official SDKs by language

Threat Jammer currently provides official SDKs for two popular programming languages: Python and Go. These SDKs are maintained by Threat Jammer to ensure compatibility with the latest API versions and to offer a reliable integration experience for developers. Each SDK is designed to encapsulate the specific functionalities of the Threat Jammer API, allowing for straightforward querying of threat data.

The Python SDK is generally preferred for data analysis, scripting, and web application backends due to its extensive ecosystem and readability. The Go SDK is often chosen for high-performance microservices, concurrent operations, and systems programming, benefiting from its strong typing and compilation to native binaries. Both SDKs provide methods for accessing core Threat Jammer products, such as the IP Reputation API and the Domain Reputation API.

The table below summarizes the key details for the official SDKs:

Language Package Name Maturity Description
Python threatjammer-py Stable Official Python client for Threat Jammer APIs, supporting IP, Domain, and ASN reputation lookups.
Go github.com/threatjammer/go-sdk Stable Official Go client for Threat Jammer APIs, designed for efficient integration in Go applications.

Installation

Installing Threat Jammer SDKs involves using the standard package managers for Python and Go. Before installation, developers should ensure they have the respective language environments set up correctly, including Python 3.7+ and Go 1.16+.

Python SDK Installation

To install the Python SDK, use pip, the Python package installer. It is recommended to install SDKs within a virtual environment to manage dependencies effectively and avoid conflicts with other projects. For detailed instructions on virtual environments, refer to the Python venv documentation.

python3 -m venv .venv
source .venv/bin/activate
pip install threatjammer-py

After installation, the threatjammer-py package will be available for import in Python scripts and applications. An API key, obtainable from the Threat Jammer authentication guide, is required for making authenticated requests.

Go SDK Installation

For the Go SDK, use go get to fetch the module and its dependencies. Go modules simplify dependency management in Go projects, eliminating the need for a global GOPATH in most modern setups. The Go SDK integrates directly into your Go project's module system.

go get github.com/threatjammer/go-sdk

Once the command completes, the SDK functions can be imported into your Go source files. Similar to the Python SDK, an API key is necessary for authenticating requests to the Threat Jammer API. Refer to the Threat Jammer API authentication details for obtaining and using your key.

Quickstart example

This section provides a quickstart example demonstrating how to use the Threat Jammer Python SDK to query the IP Reputation API. The example shows how to initialize the client with an API key and make a basic lookup request.

Python Quickstart: IP Reputation Lookup

This Python example queries the reputation of a specific IP address. Replace YOUR_API_KEY with your actual Threat Jammer API key. The response will contain a detailed reputation score and associated threat indicators for the queried IP.

import os
from threatjammer import ThreatJammerClient

# It's recommended to store your API key as an environment variable
# For demonstration, you can replace os.getenv() with your actual key string
API_KEY = os.getenv("THREATJAMMER_API_KEY", "YOUR_API_KEY")

if API_KEY == "YOUR_API_KEY":
    print("Warning: Please replace 'YOUR_API_KEY' or set the THREATJAMMER_API_KEY environment variable.")
    exit()

client = ThreatJammerClient(api_key=API_KEY)

ip_address_to_check = "8.8.8.8" # Example IP address (Google DNS)

try:
    print(f"Checking reputation for IP: {ip_address_to_check}")
    response = client.ip_reputation.get_reputation(ip=ip_address_to_check)

    if response.is_success:
        data = response.data
        print(f"IP: {data.ip}")
        print(f"Reputation Score: {data.score}")
        print(f"Threats: {', '.join(data.threats) if data.threats else 'None'}")
        print(f"Country: {data.country}")
        print(f"ASN: {data.asn.number} - {data.asn.organization}")
        if data.is_proxy:
            print("This IP is identified as a proxy.")
        if data.is_vpn:
            print("This IP is identified as a VPN.")
    else:
        print(f"Error checking IP reputation: {response.error_message}")

except Exception as e:
    print(f"An unexpected error occurred: {e}")

This example demonstrates how to instantiate the ThreatJammerClient and call the get_reputation method. The response object provides structured access to the API's output, including the IP address, reputation score, detected threats, and geographical information. For a comprehensive list of available methods and response structures, consult the Threat Jammer IP Reputation API documentation.

Go Quickstart: IP Reputation Lookup

This Go example performs a similar IP reputation lookup. It demonstrates client initialization and error handling typical in Go applications. Ensure your Go environment is correctly configured before running this code.

package main

import (
	"context"
	"fmt"
	"log"
	"os"

	threatjammer "github.com/threatjammer/go-sdk"
)

func main() {
	// It's recommended to store your API key as an environment variable
	// For demonstration, you can replace os.Getenv() with your actual key string
	apiKey := os.Getenv("THREATJAMMER_API_KEY")
	if apiKey == "" {
		log.Fatal("THREATJAMMER_API_KEY environment variable not set.")
	}

	client := threatjammer.NewClient(apiKey)

	ipAddressToCheck := "1.1.1.1" // Example IP address (Cloudflare DNS)

	ctx := context.Background()
	fmt.Printf("Checking reputation for IP: %s\n", ipAddressToCheck)
	rep, err := client.IPReputation.GetReputation(ctx, ipAddressToCheck)
	if err != nil {
		log.Fatalf("Error checking IP reputation: %v", err)
	}

	fmt.Printf("IP: %s\n", rep.IP)
	fmt.Printf("Reputation Score: %f\n", rep.Score)
	if len(rep.Threats) > 0 {
		fmt.Printf("Threats: %v\n", rep.Threats)
	} else {
		fmt.Printf("Threats: None\n")
	}
	fmt.Printf("Country: %s\n", rep.Country)
	fmt.Printf("ASN: %d - %s\n", rep.ASN.Number, rep.ASN.Organization)
	if rep.IsProxy {
		fmt.Printf("This IP is identified as a proxy.\n")
	}
	if rep.IsVPN {
		fmt.Printf("This IP is identified as a VPN.\n")
	}
}

This Go example utilizes the context package for request cancellation and timeouts, a common pattern in Go applications. The GetReputation method returns a structured response containing the IP reputation data or an error if the request fails. Developers can expand upon this basic structure to integrate threat intelligence into more complex Go-based systems, such as those described in Google's Go language overview.

Community libraries

While Threat Jammer provides official SDKs for Python and Go, the API is designed to be accessible via standard HTTP requests, allowing developers to create custom integrations in any programming language. Community-contributed libraries and wrappers can emerge over time, offering support for additional languages or specialized use cases not covered by the official SDKs. These community projects are often found on platforms like GitHub or package repositories specific to a language.

When considering a community library, it is advisable to evaluate its maintenance status, community support, and alignment with the latest Threat Jammer API specifications. Key factors for evaluation include:

  • Active Development: Check the project's commit history and issue tracker for recent activity.
  • Documentation: Assess if the library provides clear documentation and examples.
  • Testing: Look for evidence of automated tests to ensure reliability.
  • License: Understand the licensing terms for using the library in your projects.

As of the current date, Threat Jammer primarily highlights its official Python and Go SDKs. Developers interested in contributing or finding community projects are encouraged to monitor public code repositories or community forums for new developments. The underlying principles of RESTful API interaction, as detailed in the HTTP/1.1 Semantics and Content RFC, mean that custom clients can be built effectively if an official SDK is not available for a preferred language.