LogoLogo
  • Introduction
    • πŸ”΄Welcome to IntentX
    • πŸ’’The Omnichain DEX
    • ⚑User Experience Focus
    • 🌐The Meta Front-End
  • On-Chain Derivatives Overview
    • ❓What Problem Does IntentX Solve?
    • πŸ“ŠCurrent On-Chain Derivatives Landscape
    • πŸ’‘IntentX Solution & Architecture Overview
    • βœ…Comparison and Advantages of IntentX
  • IntentX Platform
    • πŸ“ˆTrading on IntentX
      • πŸ“–Trading Basics
      • 🏫Trading Tutorials
        • 🏫Web3 Wallet
        • 🏫Account Abstracted Wallet
      • 🌑️Liquidations, Margin Management (CVA), and Account Health
      • πŸ“ŠInstant 1-Click Trading
      • πŸ›‘Take Profit and Stop Loss
      • πŸ’΅Collateral & Cross-Margin Accounts
      • πŸ’ΈUnderstanding Funding Rates
      • πŸ’°Pricing Data and the Role of Oracles
      • ↕️Unrealized Profit and Loss (uPNL)
      • πŸ“Open Interest (OI) and Market Activity
      • πŸ”Withdrawal Process and Security Measures
      • πŸ“ˆAdvanced Charts by TradingView
    • πŸ”’Pair List
    • πŸŒ€IntentX Solver Network
      • πŸŒ€Example Solver Order Flow
    • πŸ«‚Referral Program
    • πŸ“±Mobile and Progressive Web App
  • Trading API
    • Introduction
    • Rest API V1
    • Typescript SDK
      • Examples
        • Opening Positions
        • Closing Positions
        • Cancel Positions
        • List Subaccounts
        • List Positions
        • Private Key Authentication
        • Enable Instant Actions
  • Tokenomics
    • πŸͺ™INTX Token and xINTX Staking
    • πŸ”„Trade & Earn xINTX
    • πŸ“…Token Allocation and Release Schedule
  • Technical Docs (WIP)
    • βš™οΈInfrastructure Overview
      • πŸ”©Technical Docs
      • 🌐Sample Solver Docs
  • Additional Information
    • ❓FAQ
    • 🌐Official Links
    • πŸ“ƒTerms & Conditions
    • πŸ”Security & Audits
    • 🌟Brand & Media Assets
    • πŸ’ΎContracts
Powered by GitBook
On this page
  • Rest API
  • Response Format
  • IntentX SDK Overview
  • Modules
  • Trade Manager
  • Markets Manager
  • Account Manager
  • Auth Manager

Trading API

PreviousMobile and Progressive Web AppNextIntroduction

Last updated 1 month ago

Rest API

We are providing a trading API that aggregates access to our decentralized protocol for developers.

The main instance of the trading API gateway is located at

From the Trading API & SDK, you'll be able to:

  • Manage your account permission (delegate accesses to other services, or your own bots)

  • Open and manage your positions

  • Get access to real time market data

  • See your portfolio

Response Format

{
success: boolean;
statusMessage: string;
data: T;
error?: {
code: string;
message: string;
};
};

IntentX SDK Overview

Modules

The IntentX SDK is structured into different modules, each responsible for handling specific protocol actions. A key aspect of using the SDK is the integration of entities that abstract complex data objects, such as positions and accounts. These entities can be managed through dedicated managers, each providing a set of essential functions.

Trade Manager

The Trade Manager module provides methods to manage trading operations, including opening and closing positions, retrieving position information, and managing take-profit/stop-loss settings.

Methods

  • createPosition(params): Opens a new position with the specified parameters.

It’s important to consider that the positions routed through the trading API will be handled by Perps Hub solver in this V1.

  • getOpenPositionsForSubaccount(subaccountAddress, chainId): Retrieves all open positions for a given subaccount.

  • getPositionInfo(positionId, chainId): Fetches detailed information about a specific position.

  • getCloseRequestInfo(closeRequestId, chainId): Retrieves details of a close request for a position.

  • closePosition(quoteId, quantityToClose, closePrice, chainId): Requests the closure of an open position.

  • setTpSlForPosition(params): Sets take-profit and stop-loss levels for a position.

  • listTpSlForPositions(chainId, quoteIds): Lists all take-profit and stop-loss configurations for a given set of positions.

  • getLockedParameters(chainId, solver, marketName, leverage): Retrieves locked parameter values for a given solver and market configuration.

Each method interacts with the IntentX trading protocol via the TradingSDK, ensuring seamless API communication and error handling.

Markets Manager

The Markets Manager module provides methods to interact with market data, including retrieving aggregated market data, specific market tickers, and solver-specific market details.

Methods

  • getAggregatedMarkets(chainId): Retrieves aggregated market data for a specific blockchain.

  • getMarketTickerById(marketId, chainId): Fetches market ticker details using a market ID.

  • getMarketTickerBySymbol(symbol, chainId): Fetches market ticker details using a market symbol.

  • getSolverMarketBySymbol(symbol, chainId, solver): Retrieves market details from a specific solver by symbol.

  • getSolverMarketById(marketId, chainId, solver): Retrieves market details from a specific solver by market ID.

  • getMarkPriceForSymbol(symbol): Gets the current mark price for a given symbol.

  • getLastPriceForSymbol(symbol): Gets the last traded price for a given symbol.

  • getMarkPricesForSymbols(symbols): Fetches mark prices for multiple symbols.

  • getLastPricesForSymbols(symbols): Fetches last traded prices for multiple symbols.

Each method ensures smooth API interaction by leveraging the TradingSDK for fetching market-related data while handling errors efficiently.

Account Manager

The Account Manager module provides methods to manage user account information, including handling subaccounts and retrieving account balance details.

Methods

  • listSubaccounts(): Retrieves a list of all subaccounts.

  • getSubaccountDetails(subaccountAddress, chainId): Fetches details of a specific subaccount.

  • getSubaccountBalanceDetails(subaccountAddress, chainId): Retrieves the balance details for a specific subaccount.

Each method leverages the TradingSDK to ensure reliable communication with the API and proper error handling.

Auth Manager

The Auth Manager module provides methods for handling authentication, permission delegation, and API key management.

Methods

  • loginWithPrivateKey(privateKey): Authenticates using a private key and stores a JWT token for subsequent requests.

  • allowInstantAction(params): Enables instant action on a subaccount by generating a SIWE signature, obtaining an access token, and updating the account configuration.

  • toggleSubaccount(params): Enables or disables access for a subaccount.

  • createApiKey(): Creates a new API key for account operations.

  • listApiKeys(): Retrieves a list of API keys.

  • validateSubaccountAccess(subaccountAddress): Checks if a subaccount has proper access and returns any instant action access details.

  • verifyInstantActionAccess(subaccountAddress, solver): Verifies whether instant action access is available for a given subaccount and solver.

  • verifyPermissionsToSubaccount(subaccountAddress, permissionsToCheck?): Verifies that the configured API key has the required permissions to operate on the subaccount.

  • validateApiKey(apiKey): Validates the provided API key, returning its identifier and validity status.

  • delegateSubaccountApiPermission(subaccountAddress, permissions, toApiKeyIdentifier): Delegates specific permissions on a subaccount to a designated API key.

Each method ensures secure communication by using JWT tokens and proper error handling via the TradingSDK.

https://gw.intentx.io/api
Page cover image