TorqueTorque

Search docs

Search Torque documentation pages & sections

Server SDKs

SDKs map to lifecycle phases. torque-node: READ + DECIDE. torque-checkout: Actions EXECUTE (merchant channel). @torquefi/react: UI hooks for READ + DECIDE. For browser UI, see React SDK. For merchants, see Actions: merchant channel, Checkout SDK, & Webhooks.

Install

# Recommended: one client for READ + DECIDE surfaces
yarn add torque-node@^0.1.4 @torquefi/types@^0.1.2

# Or split packages
yarn add torque-intelligence@^0.1.3 torque-assistant@^0.1.0

# .env (server only: never in browser bundles)
TORQUE_API_KEY=sk_live_…
TORQUE_BASE_URL=https://app.torque.fi/api/v1   # optional

Scoped @torquefi/types & @torquefi/react are required on npm. Note: torque-node@0.1.4 adds torque.read.* namespaces aligned with Assistant TI read families; publish from the monorepo before npm reflects the version.

API → SDK Coverage

DomainHTTP Guidenpm
READ: Intelligence/api/intelligencetorque.read.intelligence.*
READ: Portfolio/authentication#third-partytorque.read.portfolio.getPortfolio()
READ: Market / rates / tape / …/api/assistanttorque.read.market | rates | tape | research | plan | commerce
DECIDE: Assistant/api/assistanttorque.decide.assistant.chat(), chatStream()
Connect: Hosted execute/api/actions#third-party-handofftorque-connect createConfirmSession()
Connect: OAuth/api/actions#third-party-handofftorque-connect createAuthorizeSession(), exchangeToken()
EXECUTE: Actions (on_chain)/api/actions#onchain-channeltorque-actions + wallet/delegated JWT
EXECUTE: Actions (merchant)/api/actions#merchant-channeltorque-checkout
@torquefi/types0.1.3
torque-intelligence0.1.3
torque-node0.1.4
torque-assistant0.1.0
torque-connect0.1.0
torque-actions0.1.0
@torquefi/react0.1.1
torque-webhooks0.1.0
torque-checkout3.x

torque-node

Unified server client: one API key, one facade for READ and DECIDE surfaces.

server.ts
import { createTorqueFromEnv } from 'torque-node'

const torque = createTorqueFromEnv()

const feed = await torque.read.intelligence.getFeed({
  walletAddress: '0x…',
  chainId: 8453,
  includeBrief: true,
})
const yieldOps = await torque.read.rates.getYieldOpportunities({ walletAddress: '0x…' })
const portfolio = await torque.read.portfolio.getPortfolio({ walletAddress: '0x…' })
const chat = await torque.decide.assistant.chat({
  messages: [{ role: 'user', content: 'What moved today?' }],
  context: { walletAddress: '0x…', chainId: 8453 },
})

TI read families on 0.1.4+: torque.read.portfoliotorque.read.markettorque.read.ratestorque.read.tapetorque.read.researchtorque.read.intelligencetorque.read.plantorque.read.commerce. Subpaths: torque-node/intelligence, torque-node/assistant. Assistant streaming via chatStream(): see Assistant API.

torque-intelligence

Read-only Intelligence READ lane: feed, datasets, & markets. No Assistant chat.

getFeed()GET /api/v1/intelligence/feed
getTradeAngles() / getView('trade-angles')GET /api/v1/intelligence/views/trade-angles
getHappeningNow() / getView('happening-now')GET /api/v1/intelligence/views/happening-now
getView('brief' | 'market-outlook')GET /api/v1/intelligence/views/brief | market-outlook
getYieldOpportunities()GET /api/v1/intelligence/markets/yield
getLendingOpportunities()GET /api/v1/intelligence/markets/lending
getDataset('funding-radar')GET /api/v1/intelligence/datasets/funding-radar
getDataset('earnings-spotlight')GET /api/v1/intelligence/datasets/earnings-spotlight
getDataset('events', { days })GET /api/v1/intelligence/datasets/events

torque-assistant

chat()POST /api/v1/assistant/chat
chatStream()POST /api/v1/assistant/chat?stream=true

@torquefi/types

Types only: no runtime.

import type { IntelligenceItemV1 } from '@torquefi/types/intelligence'
import type { YieldOpportunitiesResponseV1 } from '@torquefi/types/opportunities'
import type { FundingRadarWidgetResponseV1 } from '@torquefi/types/widgets'
import type { AssistantChatPostBody } from '@torquefi/types/assistant'

torque-connect

Server-only; see Authentication.

connect.ts
import { TorqueConnect } from 'torque-connect'

const connect = new TorqueConnect({ apiKey: process.env.TORQUE_API_KEY! })
await connect.createConfirmSession({ functionResults, returnUrl, webhookUrl })
await connect.createAuthorizeSession({ redirectUri, scopes })
await connect.exchangeToken({ code, codeVerifier, redirectUri })

torque-actions

Profile C: parse signable functionResults and call execute routes with a delegated JWT.

actions.ts
import { TorqueActions } from 'torque-actions'

const actions = new TorqueActions({ accessToken: delegatedJwt })
const signable = actions.parseFunctionResults(functionResults)

Authentication

Server SDKs use sk_live_… server-side. React hooks call your BFF: never embed the key in the browser. Full table: Authentication.

Was this helpful?