Skip to content

calimero-network/calimero-client-js

Repository files navigation

SDK publish gh action npm version

Daytona logo

TypeScript Client SDK Overview

The Calimero TypeScript Client SDK helps developers interact with decentralized apps by handling server communication. It simplifies the process, letting you focus on building your app while the SDK manages the technical details. Built with TypeScript, it ensures a smoother development experience with reliable tools.

The SDK has two main parts: RpcClient for sending queries and updates to the server, and SubscriptionsClient for subscribing to real-time updates. Both are designed to be easy to use and flexible, making it simple to adapt to future updates.

Quick Examples

  1. Using JsonRpcClient:

    const rpcClient = new JsonRpcClient(
      process.env['NEXT_PUBLIC_API_URL'],
      '/jsonrpc',
    );
    const params = {
      applicationId: process.env['NEXT_PUBLIC_APPLICATION_ID'],
      method: 'create_post',
      argsJson: { title: 'My First Post', text: 'This is my first post' },
    };
    const response = await rpcClient.mutate(params);
    console.log(response);
  2. Using WsSubscriptionsClient:

    const subscriptionsClient = new WsSubscriptionsClient(
      process.env['NEXT_PUBLIC_API_URL'],
      '/ws',
    );
    await subscriptionsClient.connect();
    subscriptionsClient.subscribe([process.env['NEXT_PUBLIC_APPLICATION_ID']]);
    subscriptionsClient.addCallback((data) => console.log(data));

The SDK keeps things simple, letting you build decentralized apps efficiently without worrying about server details.