# @ton-api/client

> Autogenerated SDK for tonapi.io

Latest version **0.4.0** (published 2025-03-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ton-api/client
pnpm add @ton-api/client
yarn add @ton-api/client
bun add @ton-api/client
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 0.4.0 |
| Published | 2025-03-17 |
| First published | 2024-02-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 336.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 86 |
| Author | Ton Apps |
| Maintainers | siandreev, mois-ilya |
| Keywords | TON, Blockchain, API, TonApi |

## Links

- npm: https://www.npmjs.com/package/@ton-api/client
- Repository: https://github.com/tonkeeper/tonapi-js
- Homepage: https://github.com/tonkeeper/tonapi-js/blob/main/packages/client#readme
- Issues: https://github.com/tonkeeper/tonapi-js/issues
- npm.io page: https://npm.io/package/@ton-api/client

## Dependencies (1)

- [core-js-pure](https://npm.io/package/core-js-pure.md) ^3.38.0

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.4.0 (latest) — 2025-03-17
- 0.5.0-alpha.9 (alpha) — 2025-12-22
- 0.5.0-beta.0 (beta) — 2025-11-04
- 0.5.0-alpha.8 — 2025-12-10
- 0.5.0-alpha.7 — 2025-12-04
- 0.5.0-alpha.6 — 2025-11-14
- 0.5.0-alpha.5 — 2025-11-14
- 0.5.0-alpha.4 — 2025-11-14
- 0.5.0-alpha.3 — 2025-11-13
- 0.5.0-alpha.2 — 2025-11-13
- 0.5.0-alpha.1 — 2025-11-13
- 0.5.0-alpha.0 — 2025-11-11
- 0.4.1-alpha.1 — 2025-07-24
- 0.4.0-beta.1 — 2025-03-15
- 0.4.0-beta.0 — 2025-01-28
- … 19 more at https://npm.io/package/@ton-api/client/versions

## README

# @ton-api/client

## Overview

`@ton-api/client` is an automatically generated SDK that provides seamless access to the endpoints offered by [tonapi.io](https://tonapi.io). This client is specifically designed to integrate with the TON blockchain, offering type-safe interactions and full compatibility with @ton/core library.

## Documentation

For a detailed view of all methods and endpoints in a Swagger format, refer to the [Swagger documentation](https://tonapi.io/api-v2)
For detailed API information and endpoint descriptions, please refer to the [official documentation](https://docs.tonconsole.com/tonapi/rest-api) or check the [Swagger UI](https://tonapi.io/api-v2) for an interactive method list.

For usage examples, check the [TonAPI Cookbook](https://docs.tonconsole.com/tonapi/cookbook).

## Features

- Full coverage of tonapi.io endpoints
- Type-safe interactions with the API
- Seamless integration with `@ton/core`
<!-- - Automatically generated from the latest API specifications -->

Additionally, [`@ton-api/ton-adapter`](https://www.npmjs.com/package/@ton-api/ton-adapter) enables users to work with contracts written for `@ton/ton` through `@ton-api/client`, ensuring seamless integration while maintaining their existing code structure.

## Prerequisites

To use this SDK, you need to:

1. Set up an account at [tonconsole.com](https://tonconsole.com/)
2. Obtain an API key for authentication

## Installation

Install the package and its peer dependencies using npm, yarn, or pnpm:

```sh
npm install @ton-api/client @ton/core
# or
yarn add @ton-api/client @ton/core
# or
pnpm add @ton-api/client @ton/core
```

## Quick Start

Here's a basic example to get you started:

```javascript
import { TonApiClient } from '@ton-api/client';
import { Address } from '@ton/core';

// Initialize the TonApi
const ta = new TonApiClient({
    baseUrl: 'https://tonapi.io',
    apiKey: 'YOUR_API_KEY'
});

// Use the API
async function fetchAccountEvents() {
    const address = Address.parse('YOUR_ADDRESS_HERE');
    const events = await ta.accounts.getAccountEvents(address, { limit: 50 })
    
    console.log('Account events:', events)
}

fetchAccountEvents();
```

## Documentation

For detailed API information and endpoint descriptions, please refer to the [official documentation](https://docs.tonconsole.com/tonapi).

## Usage Examples

### Fetching NFT Collection

```javascript
const collectionAddress = Address.parse('COLLECTION_ADDRESS_HERE');

ta.nft.getNftCollection(collectionAddress)
    .then(collection => console.log('NFT Collection:', collection))
    .catch(error => console.error('Error fetching NFT collection:', error));
```

### Getting Jetton Information

```javascript
const jettonAddress = Address.parse('JETTON_ADDRESS_HERE');

ta.jettons.getJettonInfo(jettonAddress)
    .then(jetton => console.log('Jetton Info:', jetton))
    .catch(error => console.error('Error fetching jetton info:', error));
```

### Send message to blockchain

```javascript
import { beginCell, external, storeMessage, Address } from '@ton/core';

const accountAddress = Address.parse('JETTON_ADDRESS_HERE');
const exampleMessage = beginCell()
    .storeUint(0, 64)
    .endCell();
    

const messageBoc = beginCell()
    .store(
        storeMessage(
            external({
                to: address,
                body: exampleMessage
            })
        )
    )
    .endCell();

ta.blockchain.sendBlockchainMessage({
    boc: messageBoc
});
```

## License

MIT

---
_Source: https://npm.io/package/@ton-api/client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
