Getting Started


Please install the latest pycti version available from PyPI:

$ pip3 install pycti

Using the helper functions

The main class OpenCTIApiClient contains all what you need to interact with the platform, you just have to initialize it. If your OpenCTI instance requires mTLS, you can specify the paths to your cert and private key in a tuple with the cert parameter when initializing the OpenCTIApiClient. If you need to specify a path to a CA root certificate, you can do so with the ssl_verify parameter.

The following example shows how you create an indicator in OpenCTI using the python library with TLP marking and OpenCTI compatible date format.

from dateutil.parser import parse
from pycti import OpenCTIApiClient
from stix2 import TLP_GREEN

# OpenCTI API client initialization
opencti_api_client = OpenCTIApiClient("https://myopencti.server", "mysupersecrettoken")

# Define an OpenCTI compatible date
date = parse("2019-12-01").strftime("%Y-%m-%dT%H:%M:%SZ")

# Get the OpenCTI marking for stix2 TLP_GREEN
TLP_GREEN_CTI =["id"])

# Use the client to create an indicator in OpenCTI
indicator = opencti_api_client.indicator.create(
    name="C2 server of the new campaign",
    description="This is the C2 server of the campaign",
    pattern="[domain-name:value = '']",