Nex-T1 Examples
Complete, production-ready examples for every Nex-T1 API endpoint. All examples include curl, Python, and TypeScript implementations.Prerequisites:
- Nex-T1 server running (default: http://localhost:8000)
- Valid user credentials or registration
- Session token for authenticated requests
1. Authentication
Register a New User
Create a new user account before accessing protected endpoints.Expected Response
Expected Response
Login and Create Session
Login with existing credentials and create a chat session.Session Response Format
Session Response Format
Manage Sessions
List, update, and delete sessions.2. Chat & Messaging
Simple Chat Query
Send a message and receive a complete response.Streaming Chat
Receive real-time token-by-token responses using Server-Sent Events (SSE).SSE Event Format
SSE Event Format
Each SSE event follows this format:
Get and Clear Message History
Retrieve or clear all messages in a session.3. Research & Data
The Graph Subgraph Query
Query blockchain data from The Graph subgraphs.Dune Analytics Query
Execute parametrized SQL queries on Dune Analytics.DeFiLlama Multi-Source Research
Combine The Graph, Dune, and DeFiLlama data in a single request.Expected Response Structure
Expected Response Structure
4. Trading & Quotes
Get Swap Quote (EVM)
Get a pseudo-quote for an EVM token swap (development/simulation).Quote Response Format
Quote Response Format
Risk Assessment
Assess risk before executing a trade.Risk Report Format
Risk Report Format
Execute Trade (EVM)
Execute a swap on EVM chains with safety checks.Production Warning: Only execute trades with 
confirm: true when you’re ready for real transactions. Always test with simulate_only: true first.5. Multi-Agent Workflows
Intent Routing Preview
Preview how user intent is routed to specialized teams.Intent Routing Examples
Intent Routing Examples
| User Input | Intent | Team | 
|---|---|---|
| ”What’s the TVL on Ethereum?” | research | research_team | 
| ”Swap 1 ETH to USDC” | trade | trading_team | 
| ”Is this token safe to buy?” | risk_assessment | risk_team | 
| ”Get quote for ETH to DAI” | quote | trading_team | 
Full Preview Run (Research + Quote + Risk)
Execute a complete workflow including research, quote, and risk assessment.6. MCP Tool Integration
DeFiLlama Tools
List and invoke DeFiLlama MCP tools for on-chain data.Binance Market Data
Subscribe to real-time Binance market data streams.Bitcoin Tools
Access Bitcoin blockchain data and utilities.Chainlink Price Feeds
Get real-time oracle price data from Chainlink.7. Wallet & Positions
Get EVM Wallet Balance
Check wallet balance for EVM addresses.List Positions
Get all open positions filtered by agent, wallet, or token.8. Metrics & Analytics
Volume Metrics
Get total trading volume with optional filters.PnL Metrics
Get realized and unrealized profit/loss.TVL Metrics
Get Total Value Locked from agent wallets or DeFiLlama.9. Advanced Patterns
Error Handling
Robust error handling for all API calls.Retry Logic with Exponential Backoff
Handle transient failures with automatic retries.Batch Operations
Execute multiple independent operations in parallel.10. Complete Workflow Example
End-to-End Trading Flow
A complete example combining authentication, research, quote, risk assessment, and execution.Common Errors & Solutions
401 Unauthorized
401 Unauthorized
422 Validation Error
422 Validation Error
Problem: Invalid request parameters.Solutions:
- Check required fields are present
- Verify data types match schema
- Review OpenAPI spec at /openapi.json
429 Rate Limited
429 Rate Limited
Problem: Too many requests in a short time.Solutions:
- Implement exponential backoff
- Reduce request frequency
- Use batch operations when possible
Connection Refused
Connection Refused
Problem: Server not reachable.Solutions:
- Verify server is running: http://localhost:8000/health
- Check BASE_URL configuration
- Ensure firewall allows connections