This article is the consolidated API reference for the Maltego Transforms SDK (maltego-transforms): the core classes you import from maltego.server (and a couple of supporting modules) when writing transforms, entities, and transform servers. For these classes used in context, see the SDK Examples and Writing Your First Transform (Quickstart) articles in this folder.
MaltegoGraph
MaltegoGraph (maltego.server.MaltegoGraph, defined in maltego.model.graph) represents a Maltego graph as provided to a transform function: a collection of entities and the links between them. Use it as a transform's input type to receive a whole selection of entities, or as a return type to produce multiple entities with custom links between them.
Use MaltegoGraph as an input annotation to receive the entire selected graph:
from maltego.server import register_transform, MaltegoGraph
from maltego.entities import Phrase
@register_transform(
display_name="Count Entities and Links [My Transforms]",
)
async def count_graph(graph: MaltegoGraph) -> Phrase:
num_entities = len(graph.entities)
num_links = len(graph.links)
return Phrase(f"Graph has {num_entities} entities and {num_links} links")To restrict the graph to specific entity types, use a generic type parameter, e.g. MaltegoGraph[Person] (this also restricts which selections the transform appears for in the client). A transform can also return a MaltegoGraph to produce multiple entities with custom links between them, built via graph.add_entity() and graph.add_link():
from maltego.server import register_transform, MaltegoGraph
from maltego.entities import Phrase
@register_transform(
display_name="Create Linked Chain [My Transforms]",
)
async def create_chain(graph: MaltegoGraph) -> MaltegoGraph:
# Add entities to the output graph
previous = graph.add_entity(Phrase("Start"))
for i in range(5):
entity = graph.add_entity(Phrase(f"Node {i}"))
# Create a link between entities
graph.add_link(previous, entity)
previous = entity
return graphLinks can be traversed with graph.get_source() / graph.get_target():
from maltego.server import register_transform, MaltegoGraph
from maltego.entities import Phrase
@register_transform(
display_name="Analyze Connections [My Transforms]",
)
async def analyze_links(graph: MaltegoGraph) -> Phrase:
for link in graph.links:
source = graph.get_source(link) # Source entity
target = graph.get_target(link) # Target entity
label = link.label # Link label (if any)
# Analyze the relationship...
return Phrase(f"Analyzed {len(graph.links)} connections")These examples aren't exhaustive; see the SDK Examples article for more variations, including using Union types to accept multiple entity types in a typed graph input.
Constructor parameters:
| Parameter | Type | Description |
|---|---|---|
entities | Optional[List[MaltegoEntity]] | Entities to seed the graph with. |
links | Optional[List[MaltegoLink]] | Links to seed the graph with. Each link's source/target entity must already be in entities, or a ValueError is raised. |
Key methods and properties:
| Method / Property | Description | Returns |
|---|---|---|
graph.entities | All entities currently in the graph. | List[MaltegoEntity] |
graph.links | All links currently in the graph. | List[MaltegoLink] |
graph.add_entity(entity) | Adds a single entity. Raises TypeError if not a MaltegoEntity. | MaltegoEntity |
graph.add_entities(entities) | Adds a list of entities. Raises ValueError if input is not a list. | List[MaltegoEntity] |
graph.delete_entity(entity) | Deletes a single entity from the graph. | Optional[MaltegoEntity] |
graph.delete_entity_by_id(entity_id) | Deletes a single entity, looked up by its graph entity ID. | Optional[MaltegoEntity] |
graph.add_child(entity, child, link_properties=None) | Adds child to the graph and links it to entity, using the child entity's own link style/color/label/thickness settings. | MaltegoEntity |
graph.add_link(source, target, is_reversed=False, style=LinkStyle.NORMAL, color=LinkColor.NONE, thickness=LinkThickness.THICKNESS_DEFAULT, properties=None, label=None) | Adds a link between two entities (adding either entity to the graph first if not already present). | MaltegoLink |
graph.delete_link(link) | Deletes a link from the graph. | Optional[MaltegoLink] |
graph.get_entity_by_id(entity_id) | Returns the entity with the given graph entity ID, if present. | Optional[MaltegoEntity] |
graph.get_entities_of_type(entity_type_id) | Returns all entities matching a given type ID (e.g. "maltego.Phrase"). | List[MaltegoEntity] |
graph.get_entities_by_property(property_name) | Returns all entities that have a property matching the given name. | List[MaltegoEntity] |
graph.get_link_from(entity) / graph.get_links_from(entity) | Returns the first / all links originating from the given entity. | Optional[MaltegoLink] / List[MaltegoLink] |
graph.get_link_to(entity) / graph.get_links_to(entity) | Returns the first / all links pointing to the given entity. | Optional[MaltegoLink] / List[MaltegoLink] |
graph.get_link_between(source_entity, target_entity) | Returns the link between two given entities, if one exists. | Optional[MaltegoLink] |
graph.get_links_from_and_to(source_entity, target_entity) | Returns all links between two given entities in either direction. | List[MaltegoLink] |
graph.get_source(link) / graph.get_target(link) | Resolves a link's source / target entity object. | MaltegoEntity |
MaltegoEntity
MaltegoEntity (maltego.server.MaltegoEntity, defined in maltego.model.entity) is the typed base class for all Maltego entities. Transform inputs and outputs are MaltegoEntity subclasses (either the standard entities from maltego.entities or custom entities you define), and custom entity classes are declared as Python classes decorated with @register_entity.
Constructor parameters (also available as instance attributes/properties):
| Parameter | Type | Description |
|---|---|---|
value | Any | The entity's value, e.g. Phrase("Hello World"). |
weight | int, default 100 | Entity weight, shown in the Maltego client. |
maltego_entity_id | Optional[str] | Graph-unique entity ID; auto-generated if omitted. |
icon_url | Optional[str] | URL of a custom icon overlay for this entity. |
properties | Optional[Dict[str, _MaltegoEntityProperty]] | Initial property values. |
note | Optional[str] | Free-text annotation shown on the entity in the client. |
display_information | Optional[List[_DisplayInformationItem]] | Display labels/fields shown in the entity detail view. |
bookmark | Optional[Bookmark] | Bookmark color for the entity node. |
link_label, reverse_link, link_style, link_color, link_thickness | Optional[str], bool, LinkStyle, LinkColor, LinkThickness | Styling applied to the link leading into this entity when it is added as a child of another entity. |
overlays | Optional[List[Overlay]] | Icon/text overlays shown on the entity node. |
Key methods:
| Method | Description | Returns |
|---|---|---|
entity.get_property(name, default_value=None) | Returns a property's value by its property ID, or default_value if the property is absent/unset. | property value or None |
entity.set_property(name, value, display_name=None, matching_rule=None, try_parsing=True, property_type=None) | Sets a property to a value, translating internal property names to the class attribute namespace as needed. | None |
entity.has_property(property_name) | Whether the entity currently has the given property. | bool |
entity.get_properties() | All properties currently set on the entity. | Dict[str, ...] |
entity.add_display_label(name, value, content_type="text/html") | Adds a display label to the entity detail view (HTML or Markdown content). | None |
entity.add_display_field(name, value, content_type="text/html") | Adds a display field to the entity detail view. | None |
entity.add_overlay(overlay_type, position, property_name) | Adds an icon/text overlay to the entity node, sourced from a property's value. | None |
entity.icon_url (property) | Gets/sets the entity's icon overlay URL. | Optional[str] |
entity.weight (property) | Gets/sets the entity's weight. | int |
entity.note (property) | Gets/sets the entity's note annotation. | Optional[str] |
MaltegoEntityConfig
MaltegoEntityConfig (maltego.server.MaltegoEntityConfig, defined in maltego.model.entity.config) configures how a custom entity class is displayed and categorized in the Maltego client. It is assigned to a custom entity's Config class attribute.
Constructor parameters (all optional):
| Parameter | Type | Description |
|---|---|---|
value_property | Optional[str] | Name of the property used as the entity's value. |
value_key | Optional[str] | Property key used as the entity's value (alternate lookup to value_property). |
display_name | Optional[str] | Singular display name shown in the Maltego client. |
display_name_plural | Optional[str] | Plural display name; defaults to f"{display_name}s". |
description | Optional[str] | Entity description text. |
category | Optional[str] | Client-side category grouping; defaults to "Custom". |
allowed_root | bool, default True | Whether this entity type can be used as a graph root. |
overlays | Optional[List[Overlay]] | Default overlays for this entity type. |
overlay_image_property | Optional[str] | Property used to source an image overlay. |
icon_resource | Optional[Union[str, Tuple[str, str]]] | Icon resource name, or a (name, path) tuple. |
display_property | Optional[str] | Name of the property shown as the entity's display value; falls back to value_property if not set. |
display_key | Optional[str] | Property key shown as the entity's display value; falls back to value_key if not set. |
conversion_order | Optional[int] | Ordering hint used when the client resolves overlapping entity type conversions. |
converter | Optional[MaltegoEntityRegexConverter] | Regex-based value converter for this entity type. |
actions | Optional[List[MaltegoEntityAction]] | Client-side actions (e.g. "open in browser") available on this entity type. |
MaltegoEntityProperty
MaltegoEntityProperty (maltego.server.MaltegoEntityProperty, a function defined in maltego.model.entity.property) declares a single property on a custom entity class.
from maltego.entities import Person
from maltego.server import (
MaltegoEntityConfig,
MaltegoEntityProperty,
register_entity,
)
@register_entity
class StaffMember(Person):
Config = MaltegoEntityConfig(display_name="Staff Member")
employee_id: str = MaltegoEntityProperty(
display_name="Employee ID",
sample_value="E-42",
)Parameters:
| Parameter | Type | Description |
|---|---|---|
display_name | Optional[str] | Display name of this property in the Maltego client. |
name | Optional[str] | Property ID used to reference the property in the client. |
matching_rule | MatchingRule, default MATCHING_RULE_STRICT | Whether this property participates in the client's entity merge algorithm. |
value | Optional[EntityPropertyType] | Default value when used to define a full entity. |
description | str, default "" | Property description. |
hidden | bool, default False | If True, the property is not shown in the Maltego client. |
readonly | bool, default False | Whether the property can be modified by the user. |
nullable | bool, default True | Whether the property can have no value. |
sample_value | Optional[EntityPropertyType] | Sample value shown by the Maltego client. |
evaluator | Optional[str] | Optional evaluator reference for the property. |
MaltegoLink
MaltegoLink (maltego.server.MaltegoLink, defined in maltego.model.link) represents a link between two entities in a MaltegoGraph. Links are usually created via graph.add_link() or graph.add_child() rather than instantiated directly.
Constructor parameters:
| Parameter | Type | Description |
|---|---|---|
source_id | str | Graph entity ID of the link's source entity. |
target_id | str | Graph entity ID of the link's target entity. |
is_reversed | bool, default False | Whether the link direction is reversed. |
style | LinkStyle, default LinkStyle.NORMAL | Visual style of the link line. |
color | LinkColor, default LinkColor.NONE | Color of the link line. |
thickness | LinkThickness, default LinkThickness.THICKNESS_DEFAULT | Thickness of the link line. |
label | Optional[str] | Text label shown on the link. |
maltego_link_id | Optional[str] | Graph-unique link ID; auto-generated if omitted. |
properties | Optional[Dict[str, MaltegoLinkProperty]] | Initial custom link properties. |
Key methods and properties:
| Method / Property | Description | Returns |
|---|---|---|
link.get_property(name, default_value=None) | Returns a link property's value, or default_value if absent/unset. | property value or None |
link.set_property(name, value, display_name=None) | Sets a link property to a given value. | None |
link.get_properties() | All properties currently set on the link. | Dict[str, MaltegoLinkProperty] |
link.is_reversed (property) | Whether the link is reversed. | bool |
link.style (property) | The link's style. | int |
link.color (property) | The link's color. | Optional[str] |
link.thickness (property) | The link's thickness. | Optional[int] |
link.label (property) | The link's text label. | Optional[str] |
TransformSetting
TransformSetting (maltego.server.TransformSetting, defined in maltego.model.transform.setting) defines a configurable transform setting: a value the Maltego client lets the user provide per-transform (such as an API key or a numeric limit).
Constructor parameters:
| Parameter | Type | Description |
|---|---|---|
name | str | Name of the setting as referenced later in the transform function. Must be 1-128 characters, starting with a letter, digit, or underscore. |
display_name | str | Name shown to the user in the Maltego client. |
type | Union[TransformSetting.Types, str], default Types.str | The setting's type: str, float, int, boolean, date, datetime, or datetime_range. Only five of these have a _list variant for multi-value settings: str_list, float_list, int_list, boolean_list, and date_list (there is no datetime_list or datetime_range_list). |
default_value | Optional[MaltegoSettingTypes] | Default value for the setting. |
optional | bool, default True | Set to False to make the setting required on every transform execution. |
popup | bool, default False | Set to True to force a settings popup on each execution. |
is_global | bool, default False | Shares one stored setting value across transforms in the same namespace. |
is_global_setting | bool, default False | Deprecated compatibility alias for is_global (identical behavior); emits a DeprecationWarning if used. |
auth | bool, default False | Marks the setting as an authentication-related value. |
is_oauth | bool, default False | Marks the setting as an OAuth-related value. |
use_raw_name | bool, default False | Uses name verbatim instead of the SDK's namespaced setting name. |
For usage guidance, naming behavior, and worked examples, see the Transform Settings article in this folder.
MaltegoContext
MaltegoContext (maltego.server.MaltegoContext, defined in maltego.model.context) is the server-side execution context passed into a transform function, carrying request data, logging, prompts, and authentication information for the current transform run.
Selected constructor parameters (a MaltegoContext is built by the SDK server, not typically constructed by transform authors):
| Parameter | Type | Description |
|---|---|---|
graph | MaltegoGraph | The input graph for this transform run. |
request | fastapi.Request | The underlying FastAPI request object. |
api_key | Optional[str] | API key supplied with the request, if any. |
remote_ip | Optional[str] | Remote IP address of the caller. |
identity | Optional[Identity] | Verified caller identity from trusted auth validation. |
unverified_auth_claims | Optional[Dict[str, Any]] | Syntactically decoded bearer JWT/OIDC or SAML claims, populated only when AuthSettings(expose_unverified_claims=True) (or the equivalent environment variable) is set. |
Key attributes and methods:
| Attribute / Method | Description | Returns |
|---|---|---|
context.graph | The input MaltegoGraph for this run. | MaltegoGraph |
context.log | A LogCollector for sending UI messages back to the client, with inform(message), fatal(message), debug(message), and partial(message) methods. | LogCollector |
context.request (property) | The underlying FastAPI Request object. | fastapi.Request |
context.user_agent (property) | The request's User-Agent header, if present. | Optional[str] |
context.get_request_headers() | Returns the request headers as a dictionary. | Dict[str, Any] |
context.identity | Verified caller identity (from trusted auth validation only). | Optional[Identity] |
context.choice_prompt(...) / context.multi_choice_prompt(...) | Display a popup dialog (single- or multi-select) to the user and await their response mid-transform. | TransformPromptResponse |
Authentication fields
context.identity is populated only from trusted auth validation results. When AuthSettings(expose_unverified_claims=True) or MALTEGO_SERVER_AUTH_EXPOSE_UNVERIFIED_CLAIMS=true is configured, context.unverified_auth_claims may contain syntactically decoded bearer JWT/OIDC or SAML claims. This can be enabled even when auth validation itself is disabled. Those claims are not signature-verified and must not be used for authorization, tenancy, billing, auditing, or rate limiting.
TransformMiddleware
TransformMiddleware (maltego.middlewares.middlewares.TransformMiddleware) is an abstract base class for hooking into the transform execution lifecycle. Subclass it and implement both abstract methods to run custom logic before and after every transform execution.
| Class attribute | Description |
|---|---|
call_on_failure | Class attribute, default True. Whether after_transform should still be called if the transform raised an exception. |
Abstract methods to implement:
| Method | Description |
|---|---|
async before_transform(transform, transform_input, properties, context, soft_limit, hard_limit) | Called before a transform executes. Receives the MaltegoTransform object, the input entity/entities/graph, the transform settings sent by the client, the MaltegoContext, and the client's requested (soft) and maximum (hard) entity limits. |
async after_transform(transform, transform_input, output_entities, context, state, exceptions=None) | Called after a transform executes. Receives the same transform/input/context, plus the transform's output entities, its final ExecutionState, and any exceptions raised during execution. |
For middleware lifecycle guidance and registration examples, see the Transform Middlewares article in this folder.
MaltegoHubItem
MaltegoHubItem (maltego.server.MaltegoHubItem, defined in maltego.model.server) defines the metadata shown for an integration in the Maltego Hub: display name, description, icon, preview image, and provider contact details. Values can also be supplied via environment variables, since the class is a Pydantic BaseSettings model.
| Field | Type | Description |
|---|---|---|
display_name | Optional[str] | Hub item display name. |
description | Optional[str] | Hub item description. |
icon_url | Optional[str] | URL pointing to an icon (PNG) shown in the hub item panel. |
preview_image_url | Optional[str] | A preview image showcasing a graph, shown in the hub item's detail view. |
provider_name | Optional[str] | Name of the transform developer, shown in the details view. |
provider_website | Optional[str] | Website of the transform developer, shown in the details view. |
provider_email | Optional[str] | Transform developer email, shown in the details view. |
provider_phone | Optional[str] | Developer phone number, shown in the details view. |
For when to define a hub item and how to register it, see the Hub Items article in this folder.