Skip to main content

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.

Login and Create Session

Login with existing credentials and create a chat session.

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).
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.

4. Trading & Quotes

Get Swap Quote (EVM)

Get a pseudo-quote for an EVM token swap (development/simulation).

Risk Assessment

Assess risk before executing a trade.

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.

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.

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

Problem: Authentication failed or token expired.Solutions:
  • Verify credentials are correct
  • Create a new session if token expired
  • Check Authorization: Bearer <token> header format
Problem: Invalid request parameters.Solutions:
  • Check required fields are present
  • Verify data types match schema
  • Review OpenAPI spec at /openapi.json
Problem: Too many requests in a short time.Solutions:
  • Implement exponential backoff
  • Reduce request frequency
  • Use batch operations when possible
Problem: Server not reachable.Solutions:
  • Verify server is running: http://localhost:8000/health
  • Check BASE_URL configuration
  • Ensure firewall allows connections

Next Steps

API Reference

Explore detailed endpoint documentation

Multi-Agent Guide

Learn about specialized agent teams

MCP Integration

Connect external tools and data sources

Deployment

Deploy Nex-T1 to production