Get Up and Running
This quickstart guide will walk you through installing NEAR API TypeScript and sending your first transaction on the NEAR testnet.Install the Package
Install NEAR API TypeScript using your preferred package manager:
NEAR API TypeScript requires Node.js 24+ and Zod 4.3.0+. Zod is a peer dependency that you’ll need to install separately.
Create a Client
Import and create a client to connect to the NEAR testnet:The
createTestnetClient() function creates a pre-configured client with testnet RPC endpoints and automatic failover.Query Account Information
Use the client to read blockchain data:The library provides balance in both human-readable NEAR format and the native yoctoNEAR denomination.
Send a Transaction
Send NEAR tokens using the transfer action:The
near() helper converts NEAR tokens to yoctoNEAR automatically.Handle Errors
Use type-safe error handling with The
isNatError:isNatError function provides type-safe error checking with IntelliSense support.Complete Example
Here’s a complete working example that puts it all together:Next Steps
Core Concepts
Learn about clients, signers, and key services
Guides
Explore detailed guides for common tasks
API Reference
Browse the complete API documentation
Platform Support
Learn about platform-specific features
Best Practices
Use Environment Variables for Keys
Use Environment Variables for Keys
Never hardcode private keys in your source code. Always use environment variables or secure key management systems:
Choose the Right Network
Choose the Right Network
Use
createTestnetClient() for development and testing, and createMainnetClient() for production:Handle Errors Gracefully
Handle Errors Gracefully
Always wrap transaction calls in try-catch blocks and handle specific error types: