Overview
TheApi struct provides methods to perform all available read and write operations on a TAPLE node. It serves as the primary interface for interacting with the node’s functionality.
Api Struct
Fields
The libp2p peer identifier of the node.
The controller identifier string.
The public key bytes of the node.
Constructor
new
Creates a newApi instance.
This constructor is typically called internally by
Node::build and you won’t need to call it directly.Accessor Methods
peer_id
Returns the peer ID of the node.controller_id
Returns the controller ID of the node.public_key
Returns the public key of the node.Subject Methods
get_subjects
Allows to get all subjects known to the current node, regardless of their governance.The namespace to filter subjects. Use empty string for all namespaces.
Starting point for pagination. Accepts negative values to page from the end.
Number of subjects to return.
List of subject data including governance subjects.
Usage Example
get_subject
Allows to obtain a specified subject by its identifier.The identifier of the subject to retrieve.
The subject data.
Possible Errors
ApiError::InvalidParameters- If the specified identifier does not match a valid DigestIdentifierApiError::NotFound- If the subject does not exist
Usage Example
get_subjects_by_governance
Gets subjects filtered by governance ID.The governance identifier to filter by.
Starting point for pagination.
Number of subjects to return.
get_governances
Allows to obtain all subjects that model existing governance in the node.The namespace to filter governances.
Starting point for pagination.
Number of governances to return.
get_governance_subjects
Gets subjects associated with a specific governance.Event Methods
get_events
Allows to obtain events from a specific subject.The identifier of the subject.
Starting sequence number. Negative values page from the end.
Number of events to return.
List of signed events.
Usage Example
get_event
Gets a specific event by subject ID and sequence number.The subject identifier.
The sequence number of the event.
Request Methods
external_request
Allows to make a request to the node from an external invoker.A signed event request.
The identifier of the created request.
Usage Example
get_request
Retrieves a request by its identifier.The request identifier.
Approval Methods
The following methods are only available when the
approval feature is enabled.get_pending_requests
Allows to obtain all voting requests pending to be resolved in the node.List of pending approval requests.
get_single_request
Allows to obtain a single voting request.The request identifier.
Possible Errors
ApiError::InternalError- If an internal error occursApiError::NotFound- If the requested request does not exist
approval_request
Allows to vote on a voting request that exists in the system.The identifier of the request to vote on.
true to accept the request, false to reject it.The updated approval entity after voting.
Possible Errors
ApiError::InternalError- If an internal error occurs during operation executionApiError::NotFound- If the request does not exist in the systemApiError::InvalidParameters- If the specified request identifier does not match a valid DigestIdentifierApiError::VoteNotNeeded- If the node’s vote is no longer required
Usage Example
get_approval
Gets a specific approval by request ID.get_approvals
Gets approvals with optional filtering by state.Filter approvals by state (Pending, Approved, Rejected, etc.).
Starting point for pagination.
Number of approvals to return.
Authorization Methods
add_preauthorize_subject
Adds a subject to the preauthorized list with specified providers.The subject identifier to preauthorize.
Set of provider key identifiers.
get_all_allowed_subjects_and_providers
Gets all preauthorized subjects and their providers.Starting point for pagination.
Number of items to return.
Cryptographic Methods
add_keys
Adds cryptographic keys with the specified derivator.The key derivation algorithm to use (Ed25519, Secp256k1).
The identifier of the newly created key.
get_validation_proof
Gets the validation proof for a subject.The subject identifier.
Set of signatures for the validation.
The validation proof data.
Source Reference
For more details, see the source code atcore/src/api/api.rs:32-447.