Trading API
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
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.
Last updated