Files
Anthropic-Cybersecurity-Skills/skills/building-ioc-enrichment-pipeline-with-opencti/references/api-reference.md
T
mukul975 c21af3347e Complete folder anatomy for all 649 cybersecurity skills + update LICENSE to Mahipal
- Add scripts/agent.py and references/api-reference.md to all remaining skills
- Update all 648 LICENSE files: copyright now reads 'Mahipal'
- Add implementing-security-monitoring-with-datadog (new skill with full anatomy)
- All 649 skills now have: SKILL.md, LICENSE, scripts/agent.py, references/api-reference.md
2026-03-11 00:22:12 +01:00

1.8 KiB

API Reference: IOC Enrichment Pipeline with OpenCTI

pycti — OpenCTI Python Client

Installation

pip install pycti

Client Initialization

from pycti import OpenCTIApiClient

client = OpenCTIApiClient(
    url="http://localhost:8080",
    token=os.environ.get("OPENCTI_TOKEN", "")
)

Indicator Operations

# List indicators with filter
filters = {
    "mode": "and",
    "filters": [{"key": "value", "values": ["198.51.100.42"]}],
    "filterGroups": []
}
indicators = client.indicator.list(filters=filters)

# Create indicator
client.indicator.create(
    name="Malicious IP",
    pattern="[ipv4-addr:value = '198.51.100.42']",
    pattern_type="stix",
    x_opencti_score=80,
    valid_from="2025-01-01T00:00:00Z"
)

Observable Operations

# Search observables
obs = client.stix_cyber_observable.list(filters=filters)

# Create observable
client.stix_cyber_observable.create(
    observableData={
        "type": "ipv4-addr",
        "value": "198.51.100.42"
    }
)

Relationship Queries

# Get relationships from entity
rels = client.stix_core_relationship.list(
    filters={
        "mode": "and",
        "filters": [{"key": "fromId", "values": [entity_id]}],
        "filterGroups": []
    }
)

OpenCTI GraphQL API

Endpoint

POST /graphql
Authorization: Bearer <token>
Content-Type: application/json

Example Query

query {
  indicators(filters: {
    mode: and
    filters: [{ key: "value", values: ["198.51.100.42"] }]
    filterGroups: []
  }) {
    edges {
      node {
        id
        pattern
        x_opencti_score
        createdBy { name }
        objectLabel { value }
      }
    }
  }
}

STIX Indicator Patterns

Type STIX Pattern
IPv4
Domain
URL
SHA-256
MD5
Email