Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit 195e867

Browse files
author
Samuel Hassine
committed
[examples] Add searching example
1 parent 91dfcfe commit 195e867

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# coding: utf-8
2+
3+
from pycti import OpenCTIApiClient
4+
5+
# Variables
6+
api_url = "https://demo.opencti.io"
7+
api_token = "609caced-7610-4c84-80b4-f3a380d1939b"
8+
9+
# OpenCTI initialization
10+
opencti_api_client = OpenCTIApiClient(api_url, api_token)
11+
12+
# Get the ANSSI entity
13+
anssi = opencti_api_client.stix_domain_entity.get_by_stix_id_or_name(name='ANSSI')
14+
15+
# Print
16+
print(anssi)

pycti/entities/opencti_stix_domain_entity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ def get_by_stix_id_or_name(self, **kwargs):
408408
object_result = None
409409
if stix_id_key is not None:
410410
object_result = self.read(id=stix_id_key)
411-
if object_result is None and name is not None and type is not None:
411+
if object_result is None and name is not None:
412412
object_result = self.read(
413413
types=types, filters=[{"key": "name", "values": [name]}]
414414
)

0 commit comments

Comments
 (0)