---
sidebar_position: 2
---

# How to call API

Making API calls to the Lethean Daemon and Wallet is easy, below we'll give you an example to help you get started building on Lethean.

### Using Insomnia

[Insomnia](https://insomnia.rest/) is a program (similar to [postman](https://www.postman.com/)) that helps you design, debug, and test APIs, heres an example API call to the Lethean Daemon using Insomnia.

![](https://files.readme.io/d5fd42e-insomnia_call.png)

---

### Using NodeJS

Below is an example of the same API call using NodeJS:

```javascript
const axios = require("axios");

async function callAPI() {
  try {
    const url = "http://127.0.0.1:36941/json_rpc";
    const requestData = {
      jsonrpc: "2.0",
      id: 0,
      method: "getbalance",
    };

    const response = await axios.post(url, requestData);
    console.log(response.data);
    // Process the response data as needed
  } catch (error) {
    console.error("Error:", error.message);
  }
}

callAPI();
```

### Using curl

```bash
# Daemon RPC — get chain info
curl -X POST http://127.0.0.1:36941/json_rpc \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":"0","method":"getinfo"}'

# Wallet RPC — get balance (wallet must be running in RPC mode)
curl -X POST http://127.0.0.1:36944/json_rpc \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":"0","method":"getbalance"}'

# Start mining (HTTP endpoint, not JSON-RPC)
curl -X POST http://127.0.0.1:36941/start_mining \
  -H 'Content-Type: application/json' \
  -d '{"miner_address":"YOUR_iTHN_ADDRESS","threads_count":4}'

# Create integrated address (for payment tracking)
curl -X POST http://127.0.0.1:36944/json_rpc \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":"0","method":"make_integrated_address","params":{"payment_id":"1234567890abcdef"}}'
```

### Summary

| Service | Default Port | URL |
|---------|-------------|-----|
| Daemon RPC | 36941 (testnet: 46941) | `http://127.0.0.1:36941/json_rpc` |
| Wallet RPC | 36944 (testnet: 46944) | `http://127.0.0.1:36944/json_rpc` |
| Daemon P2P | 36942 (testnet: 46942) | N/A (peer connections) |

The daemon also exposes HTTP endpoints for mining control (`/start_mining`, `/stop_mining`) and binary data (`/getblocks.bin`, `/get_o_indexes.bin`).

### Libraries

- **JavaScript/TypeScript:** [`lethean_web3`](https://github.com/lethean-io) — server + browser wallet interaction
- **Node.js native:** [`lethean-util`](https://github.com/lethean-io) — address validation, block template conversion, PoW hashing (for mining pools)
- **JavaScript:** [`zano-utils-js`](https://github.com/lethean-io) — Ed25519 crypto, address encoding, transaction decoding

Have fun building on Lethean!

