This document provides step-by-step instructions for installing and configuring the TNSR API Client.
- Node.js 18+ or Bun runtime
- Network access to TNSR router
- RESTCONF API enabled on TNSR device
- Valid authentication credentials
# Install project dependencies
bun install
# Run the project
bun src/index.ts# Install project dependencies
npm install
# Compile TypeScript (if needed)
npx tsc
# Run the compiled JavaScript
node dist/index.jsUpdate the TNSR server information in src/index.ts:
const tnsrClient = new TnsrApiClient('http://YOUR_TNSR_IP:8080', 'username', 'password');Create a .env file in the project root:
TNSR_API_URL=http://192.168.1.1:8080
TNSR_USERNAME=admin
TNSR_PASSWORD=your_secure_password
TNSR_TIMEOUT=30000Then update your code to use environment variables:
import dotenv from 'dotenv';
dotenv.config();
const tnsrClient = new TnsrApiClient(
process.env.TNSR_API_URL || 'http://localhost:8080',
process.env.TNSR_USERNAME || 'tnsr',
process.env.TNSR_PASSWORD || 'password'
);const tnsrClient = new TnsrApiClient(
'https://192.168.1.1:8080', // Use HTTPS for production
'admin',
'secure_password',
{
timeout: 30000, // Request timeout in milliseconds
retries: 3, // Number of retry attempts
retryDelay: 1000, // Delay between retries in milliseconds
validateCertificate: false // Set to true for production HTTPS
}
);Visit Netgate Docs RESTCONF Server.
Test connectivity to your TNSR device:
# Test port connectivity
telnet TNSR_IP 8080
# Test HTTP connectivity
curl -u username:password http://TNSR_IP:8080/restconf/data