Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/near/near-api-ts/llms.txt

Use this file to discover all available pages before exploring further.

Welcome to NEAR API TypeScript

NEAR API TypeScript is a modern, type-safe library for building applications on the NEAR Protocol blockchain. Built from the ground up with TypeScript, it provides a robust and developer-friendly interface for interacting with NEAR Protocol in both browser and Node.js environments.

Quick Start

Get up and running in minutes with our quickstart guide

Installation

Install the library using your preferred package manager

Core Concepts

Learn the fundamental concepts behind the library

API Reference

Explore the complete API documentation

Key Features

Type-Safe

Full TypeScript support with comprehensive type definitions for all API methods

Multi-Platform

Works seamlessly in browser, Node.js, and universal environments

Flexible Error Handling

Choose between safe (Result-based) and throwable API variants

Key Management

Built-in key services with support for memory, file, and IndexedDB storage

Transaction Building

Comprehensive transaction builder with action creators

Native Token Support

First-class support for NEAR tokens and gas units with type-safe helpers

Why NEAR API TypeScript?

Modern TypeScript-First Design

Built with modern TypeScript practices, providing excellent IDE support, autocompletion, and compile-time type checking. Every function and type is fully documented with JSDoc comments.

Flexible Error Handling

Choose the error handling approach that fits your needs:
  • Throwable variants: Standard async functions that throw errors
  • Safe variants: Return Result<T, E> objects for functional error handling

Multi-Platform Support

Write once, run anywhere. The library automatically detects your environment and uses the appropriate implementation:
  • Universal: Core functionality that works everywhere
  • Browser: Browser-specific features like IndexedDB key storage
  • Node.js: Node-specific features like file-based key storage

Quick Example

import {
  createTestnetClient,
  createMemoryKeyService,
  createMemorySigner,
  transfer,
  near,
} from 'near-api-ts';

// Create a client
const client = createTestnetClient();

// Query account information
const { accountInfo } = await client.getAccountInfo({
  accountId: 'testnet',
  atMomentOf: 'LatestFinalBlock',
});

console.log('Balance:', accountInfo.balance.total.near);

// Set up signing with a key service
const keyService = createMemoryKeyService({
  keySource: { privateKey: 'ed25519:your-private-key' },
});

const signer = createMemorySigner({
  signerAccountId: 'your-account.testnet',
  client,
  keyService,
});

// Send a transaction
await signer.executeTransaction({
  intent: {
    action: transfer({ amount: near('1') }),
    receiverAccountId: 'receiver.testnet',
  },
});

Next Steps

Install the Library

Learn how to install NEAR API TypeScript in your project

Follow the Quickstart

Build your first NEAR application in 5 minutes

Understand Clients

Learn about RPC clients and network connections

Explore Examples

See real-world usage examples and patterns

Community and Support

Build docs developers (and LLMs) love