Skip to content
prasad-kumkar edited this page May 5, 2025 · 1 revision

API

The jam.api module provides interfaces for interacting with the Tessera node, including both RPC (Remote Procedure Call) and REST API endpoints.

API Types

Tessera supports multiple API interfaces:

  • JSON-RPC API: Primary interface for programmatic interaction with the node
  • REST API: HTTP-based interface for querying node state and submitting transactions
  • WebSocket API: For subscribing to events and real-time updates

Core Functionality

Chain Information

  • Query current blockchain height
  • Get block information by hash or height
  • Get transaction information by hash
  • Query network status and synchronization progress

State Queries

  • Query current state values
  • Generate state proofs
  • Retrieve account information

Transaction Submission

  • Submit extrinsics to the network
  • Check transaction status and inclusion
  • Query transaction fees

Validator Operations

  • Query validator information
  • Submit validator-specific transactions
  • Monitor validation performance

JSON-RPC Methods

The JSON-RPC API exposes methods with the following format:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "module_methodName",
  "params": [param1, param2, ...]
}

Common method namespaces include:

  • jam_: Core node methods
  • state_: State query methods
  • chain_: Chain information methods
  • author_: Methods for authoring blocks and submitting transactions
  • system_: Node system information

API Configuration

API services can be configured through the node configuration:

# Configure API endpoints in node setup
node_config = {
    "api": {
        "http_enabled": True,
        "http_port": 9933,
        "ws_enabled": True,
        "ws_port": 9944,
        "cors_origins": ["*"],
        "max_connections": 100
    }
}

# Initialize node with configuration
node = JamNode(config=node_config)

Authentication and Security

Tessera API endpoints support various authentication mechanisms:

  • API keys for programmatic access
  • JWT tokens for authenticated sessions
  • IP-based access control

These security features can be configured in the node configuration.

Clone this wiki locally