Install and configure the Treeship SDK for your project
npm install @treeship/sdk
yarn add @treeship/sdk
pnpm add @treeship/sdk
pip install treeship-sdk
poetry add treeship-sdk
.env
# .env TREESHIP_API_KEY=your_api_key_here TREESHIP_ENVIRONMENT=production # or "sandbox" for testing
.gitignore
echo ".env" >> .gitignore
import { Treeship } from '@treeship/sdk'; const treeship = new Treeship({ apiKey: process.env.TREESHIP_API_KEY, environment: process.env.TREESHIP_ENVIRONMENT || 'production' }); // Test your connection try { const status = await treeship.health.check(); console.log('Connected to Treeship:', status); } catch (error) { console.error('Connection failed:', error); }
const treeship = new Treeship({ apiKey: process.env.TREESHIP_API_KEY, baseUrl: 'https://api.your-domain.com/v1', timeout: 30000, // 30 seconds retries: 3 });
const treeship = new Treeship({ apiKey: process.env.TREESHIP_API_KEY, httpAgent: new HttpsProxyAgent('http://proxy.company.com:8080') });
const { Treeship } = require('@treeship/sdk'); async function verifyInstallation() { try { const treeship = new Treeship({ apiKey: process.env.TREESHIP_API_KEY }); // Check API connection const health = await treeship.health.check(); console.log('✅ API Connection:', health.status); // Check ZK proof generation capability const zkTest = await treeship.proofs.test(); console.log('✅ ZK Proof Generation:', zkTest.status); console.log('\n🎉 Treeship SDK installed successfully!'); } catch (error) { console.error('❌ Installation verification failed:', error.message); } } verifyInstallation();
Module not found error
# Check if you're in the right directory pwd # List installed packages npm list @treeship/sdk
Authentication failed
# Check if environment variable is set echo $TREESHIP_API_KEY # Make sure .env is loaded (for Node.js) npm install dotenv
require('dotenv').config();
Connection timeout
# Test API endpoint curl -I https://api.treeship.dev/v1/health