pypergraph.network.api package

Submodules

pypergraph.network.api.block_explorer_api module

class pypergraph.network.api.block_explorer_api.BlockExplorerApi(host: str, client: RESTClient | None = None, timeout: int = 25)[source]

Bases: object

config(host: str | None = None, client: RESTClient | None = None)[source]

Reconfigure the RestAPIClient.

async get_address_balance(hash: str) Balance[source]

Retrieve the balance for a given address from the block explorer.

Parameters:

hash – Address hash.

Returns:

Balance object.

async get_currency_address_balance(metagraph_id: str, hash: str) Balance[source]
async get_currency_snapshot(metagraph_id: str, hash_or_ordinal: str) CurrencySnapshot[source]
async get_currency_snapshot_rewards(metagraph_id: str, hash_or_ordinal: str) List[RewardTransaction][source]
async get_currency_transaction(metagraph_id: str, hash: str) Transaction[source]
async get_currency_transactions(metagraph_id: str, limit: int | None, search_after: str | None = None, search_before: str | None = None) List[Transaction][source]
async get_currency_transactions_by_address(metagraph_id: str, address: str, limit: int = 0, search_after: str = '', sent_only: bool = False, received_only: bool = False, search_before: str = '') List[Transaction][source]
async get_currency_transactions_by_snapshot(metagraph_id: str, hash_or_ordinal: str, limit: int = 0, search_after: str = '', search_before: str = '') List[Transaction][source]
async get_latest_currency_snapshot(metagraph_id: str) CurrencySnapshot[source]
async get_latest_currency_snapshot_rewards(metagraph_id: str) List[RewardTransaction][source]
async get_latest_snapshot() Snapshot[source]

Get the latest snapshot from the block explorer.

Returns:

Snapshot object.

async get_latest_snapshot_rewards() List[RewardTransaction][source]
async get_latest_snapshot_transactions() List[Transaction][source]

Retrieve transactions for the latest snapshot.

Returns:

List of Transaction objects.

async get_rewards_by_snapshot(id: str | int) List[RewardTransaction][source]

Retrieve reward objects for a given snapshot.

Parameters:

id – Hash or ordinal.

Returns:

List of Reward objects.

async get_snapshot(id: str | int) Snapshot[source]

Retrieve a snapshot by its hash or ordinal.

Parameters:

id – Hash or ordinal identifier.

Returns:

Snapshot object.

async get_transaction(hash: str) Transaction[source]

Retrieve a transaction by its hash.

Parameters:

hash – Transaction hash.

Returns:

Transaction object.

async get_transactions(limit: int | None, search_after: str | None = None, search_before: str | None = None) List[Transaction][source]

Get transactions from the block explorer. Supports pagination.

Parameters:
  • limit – Maximum number of transactions.

  • search_after – Pagination parameter.

  • search_before – Pagination parameter.

Returns:

List of Transaction objects.

async get_transactions_by_address(address: str, limit: int = 0, search_after: str = '', sent_only: bool = False, received_only: bool = False, search_before: str = '') List[Transaction][source]

Retrieve transactions for a specific DAG address. Supports pagination.

Parameters:
  • address – DAG address.

  • limit – Maximum number of transactions.

  • search_after – Pagination parameter.

  • sent_only – Filter for sent transactions.

  • received_only – Filter for received transactions.

  • search_before – Pagination parameter.

Returns:

List of Transaction objects.

async get_transactions_by_snapshot(id: str | int) List[Transaction][source]

Retrieve transactions for a given snapshot.

Parameters:

id – Hash or ordinal identifier.

Returns:

List of Transaction objects.

pypergraph.network.api.layer_0_api module

class pypergraph.network.api.layer_0_api.L0Api(host: str, client: RESTClient | None = None, timeout: int = 25)[source]

Bases: object

config(host: str | None = None, client: RESTClient | None = None)[source]

Reconfigure the RestAPIClient.

async get_address_balance(address: str) Balance[source]
async get_cluster_info() List[PeerInfo][source]
async get_delegated_stake_last_reference(address: str) TransactionReference[source]
async get_delegated_stakes_info(address) DelegatedStakesInfo[source]
async get_delegated_stakes_reward_info()[source]
async get_latest_snapshot() SignedGlobalIncrementalSnapshot[source]
async get_latest_snapshot_ordinal() Ordinal[source]
async get_metrics() List[Dict[str, Any]][source]

Get metrics from the L0 endpoint.

Returns:

Prometheus output as a list of dictionaries.

async get_node_collateral_last_reference(address: str) TransactionReference[source]
async get_node_collaterals_info(address) NodeCollateralsInfo[source]
async get_node_parameters(search_name_or_id: str | None = None, sort: Literal['name', 'peerID', 'address', 'totalAddressesAssigned', 'totalAmountDelegated'] | None = None, sort_order: Literal['ASC', 'DESC'] | None = None)[source]
async get_node_parameters_by_address(address)[source]
async get_total_supply() TotalSupply[source]
async post_delegated_stake(tx: SignedCreateDelegatedStake)[source]
async post_node_collateral(tx: SignedCreateNodeCollateral)[source]
async post_node_parameters(tx: SignedUpdateNodeParameters)[source]

Register validator parameters for delegated staking

async post_state_channel_snapshot(address: str, snapshot: dict)[source]
async put_delegated_stake_withdrawal(tx: SignedWithdrawDelegatedStake)[source]
async put_node_collateral_withdrawal(tx: SignedWithdrawNodeCollateral)[source]

pypergraph.network.api.layer_1_api module

class pypergraph.network.api.layer_1_api.L1Api(host: str, client: RESTClient | None = None, timeout: int = 25)[source]

Bases: object

config(host: str | None = None, client: RESTClient | None = None)[source]

Reconfigure the RestAPIClient.

async get_allow_spend_last_reference(address: str) AllowSpendReference[source]
async get_cluster_info() List[PeerInfo][source]
async get_last_reference(address: str) TransactionReference[source]
async get_metrics() List[Dict[str, Any]][source]

Get metrics from the L1 endpoint.

Returns:

Prometheus output as a list of dictionaries.

async get_pending_transaction(hash: str) PendingTransaction[source]
async get_token_lock_last_reference(address: str) TokenLockReference[source]
async post_allow_spend(tx: SignedAllowSpend)[source]
async post_token_lock(tx: SignedTokenLock)[source]
async post_transaction(tx: SignedTransaction)[source]

pypergraph.network.api.metagraph_currency_layer_1_api module

class pypergraph.network.api.metagraph_currency_layer_1_api.ML1Api(host: str, client: RESTClient | None = None, timeout: int = 25)[source]

Bases: L1Api

pypergraph.network.api.metagraph_data_layer_1_api module

class pypergraph.network.api.metagraph_data_layer_1_api.MDL1Api(host: str, client: RESTClient | None = None, timeout: int = 25)[source]

Bases: object

config(host: str | None = None, client: RESTClient | None = None)[source]

Reconfigure the RestAPIClient.

async get_cluster_info() List[PeerInfo][source]
async get_data() List[SignedTransaction][source]

Retrieve enqueued data update objects.

async get_metrics() List[Dict[str, Any]][source]

Get metrics from the Metagraph data layer 1 endpoint.

Returns:

Prometheus output as a list of dictionaries.

async post_data(tx: Dict)[source]

Submit a data update object for processing.

Parameters:

tx – SignedTransaction object containing data and proofs

pypergraph.network.api.metagraph_layer_0_api module

class pypergraph.network.api.metagraph_layer_0_api.ML0Api(host: str, client: RESTClient | None = None, timeout: int = 25)[source]

Bases: L0Api

async get_address_balance(address: str) Balance[source]
async get_address_balance_at_ordinal(ordinal: int, address: str) Balance[source]
async get_total_supply() TotalSupply[source]
async get_total_supply_at_ordinal(ordinal: int) TotalSupply[source]

Module contents

class pypergraph.network.api.BlockExplorerApi(host: str, client: RESTClient | None = None, timeout: int = 25)[source]

Bases: object

config(host: str | None = None, client: RESTClient | None = None)[source]

Reconfigure the RestAPIClient.

async get_address_balance(hash: str) Balance[source]

Retrieve the balance for a given address from the block explorer.

Parameters:

hash – Address hash.

Returns:

Balance object.

async get_currency_address_balance(metagraph_id: str, hash: str) Balance[source]
async get_currency_snapshot(metagraph_id: str, hash_or_ordinal: str) CurrencySnapshot[source]
async get_currency_snapshot_rewards(metagraph_id: str, hash_or_ordinal: str) List[RewardTransaction][source]
async get_currency_transaction(metagraph_id: str, hash: str) Transaction[source]
async get_currency_transactions(metagraph_id: str, limit: int | None, search_after: str | None = None, search_before: str | None = None) List[Transaction][source]
async get_currency_transactions_by_address(metagraph_id: str, address: str, limit: int = 0, search_after: str = '', sent_only: bool = False, received_only: bool = False, search_before: str = '') List[Transaction][source]
async get_currency_transactions_by_snapshot(metagraph_id: str, hash_or_ordinal: str, limit: int = 0, search_after: str = '', search_before: str = '') List[Transaction][source]
async get_latest_currency_snapshot(metagraph_id: str) CurrencySnapshot[source]
async get_latest_currency_snapshot_rewards(metagraph_id: str) List[RewardTransaction][source]
async get_latest_snapshot() Snapshot[source]

Get the latest snapshot from the block explorer.

Returns:

Snapshot object.

async get_latest_snapshot_rewards() List[RewardTransaction][source]
async get_latest_snapshot_transactions() List[Transaction][source]

Retrieve transactions for the latest snapshot.

Returns:

List of Transaction objects.

async get_rewards_by_snapshot(id: str | int) List[RewardTransaction][source]

Retrieve reward objects for a given snapshot.

Parameters:

id – Hash or ordinal.

Returns:

List of Reward objects.

async get_snapshot(id: str | int) Snapshot[source]

Retrieve a snapshot by its hash or ordinal.

Parameters:

id – Hash or ordinal identifier.

Returns:

Snapshot object.

async get_transaction(hash: str) Transaction[source]

Retrieve a transaction by its hash.

Parameters:

hash – Transaction hash.

Returns:

Transaction object.

async get_transactions(limit: int | None, search_after: str | None = None, search_before: str | None = None) List[Transaction][source]

Get transactions from the block explorer. Supports pagination.

Parameters:
  • limit – Maximum number of transactions.

  • search_after – Pagination parameter.

  • search_before – Pagination parameter.

Returns:

List of Transaction objects.

async get_transactions_by_address(address: str, limit: int = 0, search_after: str = '', sent_only: bool = False, received_only: bool = False, search_before: str = '') List[Transaction][source]

Retrieve transactions for a specific DAG address. Supports pagination.

Parameters:
  • address – DAG address.

  • limit – Maximum number of transactions.

  • search_after – Pagination parameter.

  • sent_only – Filter for sent transactions.

  • received_only – Filter for received transactions.

  • search_before – Pagination parameter.

Returns:

List of Transaction objects.

async get_transactions_by_snapshot(id: str | int) List[Transaction][source]

Retrieve transactions for a given snapshot.

Parameters:

id – Hash or ordinal identifier.

Returns:

List of Transaction objects.

pypergraph.network.api.Layer0Api

alias of L0Api

pypergraph.network.api.Layer1Api

alias of L1Api

pypergraph.network.api.MetagraphCurrencyLayerApi

alias of ML1Api

pypergraph.network.api.MetagraphDataLayerApi

alias of MDL1Api

pypergraph.network.api.MetagraphLayer0Api

alias of ML0Api