
Earn API
Trade: Perps API
Borrow API
Before you start
Create a team and project in the Yield.xyz dashboard, then generate an API key. Include the key in thex-api-key header when making requests to the APIs.
Your project determines which products and opportunities are available to your integration. Some capabilities, including Borrow and certain trading integrations, may require access to be enabled for your team.
buy, sell and manage across perps, spot, prediction markets and tokenized stocks. See Trade.Earn API
The Earn API provides access to 4,000+ yield opportunities across 85+ networks, including staking, DeFi, stablecoin strategies, and tokenized real-world assets. The integration follows a consistent lifecycle: discover an opportunity, inspect its requirements, construct an action, sign and submit the transactions, and track the resulting position.Discover available yields
GET /v1/yields to retrieve the opportunities enabled for your project. You can filter the results by network, token, provider, or yield type, depending on the available query parameters.Each opportunity has a unique id, which is used when requesting actions and retrieving position information.GET /v1/yields returns opportunities enabled for your project. Enable additional yields in the dashboard before attempting to discover or integrate them.Inspect the required arguments
GET /v1/yields/{yieldId}.The response includes mechanics.arguments.enter.fields, which describes the inputs required to construct an enter action. These requirements can differ between opportunities.For example, an ETH staking opportunity may require an amount, while validator-based staking can require additional information such as validatorAddress.Construct an enter action
POST /v1/actions/enter with the selected yieldId, the user’s wallet address, and the required arguments.The response contains an action with an ordered transactions array. Each transaction includes the unsigned transaction data required for execution.Sign, submit, and track transactions
unsignedTransaction to your application’s signer, which can be an EOA, smart account, MPC wallet, or institutional custody provider.Once a transaction has been signed and broadcast, report its hash using PUT /v1/transactions/{transactionId}/submit-hash.SUCCESS or FAILED.Retrieve the resulting position
POST /v1/yields/{yieldId}/balances to retrieve the user’s position.active, entering, exiting, withdrawable, claimable, and locked.Some positions also expose pendingActions, including reward claims or withdrawal-related actions. These can be handled through the corresponding manage flow using POST /v1/actions/manage.See Balances and positions for lifecycle states, pending actions, and position management.Perps API
The Perps API lets applications offer perpetual futures trading on Hyperliquid without integrating the venue directly. The API returns markets, builds trading actions for you to sign, submits the signed orders to the venue and tracks positions. The following example opens a leveraged position on Hyperliquid.Discover trading markets
GET /v1/markets to retrieve available markets. Filter by providerId to select a supported trading venue.Market information includes identifiers, leverage limits, trading fees, funding rates, and minimum position requirements.id for the trading action.Construct a trading action
POST /v1/actions to construct an order.The request includes the trading venue, wallet address, action type, and market-specific arguments.To open a position, provide the market, direction, margin or position size, and leverage.amount represents the margin in USD, while leverage determines the corresponding position notional.You can alternatively provide size to specify the position size in USD. The position notional must meet the venue’s minimum requirement, which is at least 10 USD for the example described here.fund action before submitting the order.Sign and submit the transaction
signingFormat and signablePayload.Trading actions may use typed-data signing, such as EIP712_TYPED_DATA, rather than a standard unsigned blockchain transaction.Sign the returned payload using your wallet or signing provider, then submit the signature through POST /v1/transactions/{transactionId}/submit.Track open positions
POST /v1/positions to retrieve positions associated with the user’s wallet and trading venue.Borrow API
The Borrow API lets users borrow against their crypto across Aave V3, SparkLend, Morpho Blue and Lista, with Compound V3 being added. Every market is returned in the same shape. You can discover lending markets, supply assets, enable collateral where required, borrow, repay and withdraw through the same action model.Discover lending markets
GET /v1/markets to retrieve supported lending markets.Markets can be filtered by network or integration, and each result includes an id and the integrationId identifying the underlying protocol integration.Construct a lending action
POST /v1/actions with the market’s integrationId, the user’s address, the requested action, and its arguments.Supported actions include:tokenAddress to identify the asset.enableCollateral and disableCollateral apply to supported pooled markets.Sign and submit transactions
signingFormat and signablePayload.Sign and submit the transactions one at a time, in the order returned, using POST /v1/transactions/{transactionId}/submit. Before you submit the next one, poll GET /v1/actions/{id} until the previous transaction is CONFIRMED: a SUPPLY submitted before its APPROVAL confirms reverts.If you have already broadcast the transaction, provide its hash:signedPayload and let Yield.xyz broadcast the signed transaction.An action can return several transactions, for example an APPROVAL before a SUPPLY. Submit them in order, and wait for each one to confirm before you submit the next. Every transaction comes back in the first response: Borrow actions return hasNextStep: false, so there is no next step to request.Retrieve the borrowing position
GET /v1/positions with the user’s wallet address, network, and protocol integration.
