API Endpoints
Hyperswap AI will offer a powerful API for developers to integrate seamlessly, AI-powered crypto swaps into their applications.
The API is currently in testing phase. If you need early access please contact us.
Enterprise users of integrations can swap at the same rate as directly on the HyperSwap.ai website; the 0.5% commission will not be added on top of API swaps.
Features of the API
- AI-Powered Smart Routing: Finds the best liquidity pools for minimal slippage.
- Multi-Chain Support: Works across Ethereum, Solana, Bitcoin and other 72+ popular chains supporting more than 15000 assets across those chains.
- Real-Time Exchange Rates: Fetch live rates optimized by AI.
- Swap Execution: Initiate crypto swaps directly via API.
- Transaction Monitoring: Track swap status with webhooks.
API Endpoints # Hyperswap API Endpoints Documentation
This document provides a comprehensive overview of the public API endpoints for Hyperswap, detailing their functionality, parameters, responses, and important considerations for integration.
Base URL
All API endpoints are relative to the following base URL:
https://api.hyperswap.ai
Authentication
All API endpoints require authentication using an API key.
- API Key Issuance: API keys are issued manually to clients.
- Sign-Up: To request an API key and become a client, please sign up at: https://www.hyperswap.ai/partner-request
- Usage: Once you have an API key, include it in the
Authorization
header of your requests as a Bearer token:Authorization: Bearer YOUR_API_KEY
Available Values and Data Sources
This section explains how to obtain the dynamic values required for certain API parameters and lists fixed possible values for others.
Chain IDs (chainId
)
Chain IDs represent different blockchains supported by Hyperswap.
- Source: These can be obtained by calling the
/api/v1/assets
endpoint. EachStandardizedAsset
object in the response includes achainId
field. - Format: Chain IDs can be numerical (for EVM chains) or string identifiers (for non-EVM chains).
- Examples:
- EVM Chains (Numerical):
1
(Ethereum),56
(BNB Chain),137
(Polygon),42161
(Arbitrum One),10
(Optimism),8453
(Base),43114
(Avalanche),25
(Cronos),324
(ZkSync Era),59144
(Linea). - Non-EVM Chains (String Identifiers/Internal Mappings):
'1151111081099710'
(Solana),'20000000000001'
(Bitcoin),'9270000000000000'
(Sui),'TRON'
(Tron),'TON'
(TON),'APTOS'
(Aptos),'ALGORAND'
(Algorand),'BITTENSOR'
(Bittensor),'CARDANO'
(Cardano),'CELESTIA'
(Celestia),'COSMOS'
(Cosmos),'DASH'
(Dash),'DOGE'
(Dogecoin),'HEDERA'
(Hedera),'ICP'
(Internet Computer),'LITECOIN'
(Litecoin),'MANTLE'
(Mantle),'POLKADOT'
(Polkadot),'RIPPLE'
(Ripple),'RONIN'
(Ronin),'STACKS'
(Stacks),'STELLAR'
(Stellar),'XEC'
(eCash),'BCH'
(Bitcoin Cash),'LIQUID'
(Liquid),'HYPEREVM'
(Hyperevm),'SONIC'
(Sonic),'BLAST'
(Blast),'SCROLL'
(Scroll),'FETCH'
(Fetch).
- EVM Chains (Numerical):
- Note: The
chainName
andchainLogoUrl
fields in the asset response can help identify the human-readable name and logo for each chain. For the most current list of supported chains, always query the/api/v1/assets
endpoint.
Token Addresses (fromToken
, toToken
)
Token addresses identify specific crypto assets on a given blockchain.
- Source: These are obtained by calling the
/api/v1/assets
endpoint. EachStandardizedAsset
object includes anaddress
field, which represents the token’s contract address on its respectivechainId
. - Native Tokens: For native blockchain tokens (e.g., ETH on Ethereum, BTC on Bitcoin, SOL on Solana, SUI on Sui), specific normalized addresses are used:
- EVM Native:
0x0000000000000000000000000000000000000000
- Bitcoin:
'bitcoin'
- Solana:
'11111111111111111111111111111111'
- Sui:
'0x2::sui::SUI'
- EVM Native:
- Note: The
symbol
andname
fields in the asset response provide human-readable identifiers for the tokens.
Preference (preference
)
This parameter allows specifying the desired optimization for a quote.
- Possible Values:
'fastest'
: Prioritizes quotes with the quickest estimated completion time.'lowest_cost'
: Prioritizes quotes with the lowest estimated fees.
Transaction Statuses (status
)
These are the possible states for a swap transaction.
- Possible Values:
PENDING
: The transaction has been initiated but is awaiting further action (e.g., user deposit for hyperswapshift, user signature for hyperswap).IN_PROGRESS
: The swap is actively being processed by the liquidity provider.COMPLETED
: The swap has successfully finished, and funds have been settled.FAILED
: The swap encountered an unrecoverable error.REFUNDED
: The swap failed, and funds have been returned to the refund address.
API Endpoints
1. Get All Assets
GET /api/v1/assets
-
Description: Fetches a comprehensive list of standardized crypto assets supported by the platform, aggregating data from hyperswap and hyperswapshift. This endpoint is essential for populating token selection interfaces and understanding available assets.
-
Query Parameters:
chainId
(optional,string | number
): Filters the returned assets to a specific blockchain.
-
Response (JSON Array of StandardizedAsset objects):
source
(string
): The data source (‘hyperswap’).name
(string
): Full name of the asset.symbol
(string
): Symbol of the asset.chainId
(string | number
): The ID of the blockchain the asset belongs to.address
(string
): The contract address of the asset. For native tokens, specific normalized addresses are used (see “Token Addresses” section above).decimals
(number
): The number of decimal places for the asset.logoUrl
(string
): URL to the asset’s logo.chainLogoUrl
(string
): URL to the logo of the chain the asset belongs to.chainName
(string
): Name of the chain the asset belongs to.priceUsd
(number
, optional): The price of the asset in USD.swappable
(boolean
): Indicates if the asset is swappable (alwaystrue
).providerId
(object
): An object containing provider-specific IDs for the asset.hyperswap
(string
, optional): hyperswap identifier.hyperswapshift
(string
, optional): hyperswapshift identifier.
priorityOrder
(number
, optional): A numerical order indicating the asset’s priority (e.g., native tokens, stablecoins).isPriorityToken
(boolean
, optional): Indicates if the asset is a priority token.
-
Error Responses:
500 Internal Server Error
:{ "message": "Failed to fetch assets", "error": "An unknown error occurred" }
-
Notes:
- Responses are cached for 5 minutes to improve performance.
- The
chainId
parameter can accept various formats, which are normalized internally.
2. Get Preview Quotes
POST /api/v1/quote
-
Description: Generates preview quotes for a token swap across different chains and tokens, aggregating results from various liquidity providers. These quotes are estimates and should be used for display purposes. A
quoteId
is returned for use in the/api/v1/swap
endpoint. -
Authentication: Required.
-
Request Body (JSON):
fromChain
(number
): The ID of the source blockchain. (See “Chain IDs” section for available values).toChain
(number
): The ID of the destination blockchain. (See “Chain IDs” section for available values).fromToken
(string
): The contract address of the source token. For native tokens, use the normalized address. (See “Token Addresses” section for available values).toToken
(string
): The contract address of the destination token. (See “Token Addresses” section for available values).fromAmount
(string
): The amount of the source token to swap, always in wei (the smallest unit of the token, e.g., for ETH, 1 ETH = 10^18 wei).fromAddress
(string
): The user’s wallet address on the source chain.toAddress
(string
, optional): The user’s wallet address on the destination chain. If not provided, thefromAddress
might be used as a fallback by some providers, but it’s best to explicitly provide it if known.fromDecimals
(number
): The number of decimals for thefromToken
.toDecimals
(number
): The number of decimals for thetoToken
.preference
('fastest' | 'lowest_cost'
): The user’s preference for quote selection. (See “Preference” section for available values).
-
Response (JSON):
quotes
(Array<object>
): An array of preview quotes, typically returning the top 2 based on thepreference
.quoteId
(string
): A unique identifier for the quote, to be used in the/api/v1/swap
endpoint.provider
(string
): The name of the liquidity provider (‘hyperswap’).toAmount
(string
): The estimated amount of destination token received (in wei).estimatedTime
(number
): Estimated time in seconds for the swap to complete.fees
(Array<object>
, optional): Details about any fees associated with the swap.type
(string
, optional): Specific type of swap (e.g., ‘standard’ for hyperswapshift).chainId
(string | number
): The chain ID for the quote.isPreview
(boolean
): Alwaystrue
for these preview quotes.
bestQuote
(object
): The best quote from thequotes
array based on thepreference
.providerErrors
(object
, optional): An object containing errors from individual liquidity providers if any failed to return quotes.isPreview
(boolean
): Alwaystrue
.message
(string
): A descriptive message indicating that these are preview quotes.
-
Error Responses:
400 Bad Request
:{ "message": "fromChain, toChain, fromToken, toToken, fromAmount, fromAddress, and preference are required" }
{ "message": "preference must be either \"fastest\" or \"lowest_cost\"" }
{ "message": "Invalid fromToken or toToken", "details": { "fromTokenValid": false, "toTokenValid": true } }
{ "message": "No routes available for this token pair", "error": "ROUTE_NOT_SUPPORTED" }
503 Service Unavailable
:{ "message": "Service temporarily unavailable" }
(e.g., if TokenService initialization fails).500 Internal Server Error
:{ "message": "Failed to generate quotes. Please try again.", "error": "An unknown error occurred" }
-
Notes:
- Quotes are cached internally for a short period for later retrieval during the swap process.
- The
fromAmount
must be provided in the smallest unit (wei) of thefromToken
.
3. Initiate Swap
POST /api/v1/swap
- Description: Initiates a token swap based on a previously generated quote. This endpoint interacts with the chosen liquidity provider (hyperswap or hyperswapshift) to create the actual transaction or shift.
- Authentication: Required.
- Request Body (JSON):
-
Common Fields:
provider
('hyperswap'
): The liquidity provider to use. (See “Provider” section for available values).settleAddress
(string
): The address where the swapped tokens should be sent.refundAddress
(string
, optional): The address for refunds in case of issues. This is crucial for hyperswapshift swaps.clientId
(string
): A unique identifier for your client application.preference
('fastest' | 'lowest_cost'
, optional): The preference used for the original quote.settleMemo
(string
, optional): Memo or tag for the settle address (e.g., for exchanges that require it).refundMemo
(string
, optional): Memo or tag for the refund address.
-
For provider: 'hyperswap' (additional fields):
- These fields are used to generate a fresh quote from hyperswap at the time of swap initiation.
-
For provider: 'hyperswapshift' (additional fields):
quoteId
(string
): ThequoteId
obtained from the/api/v1/quote
endpoint.
-
- Response (JSON):
-
For hyperswap Swaps (provider: 'hyperswap'):
transactionRequest
(object
): Details for the transaction that needs to be signed by the user’s wallet.type
(string
): Indicates the chain type (‘evm’, ‘solana’, or ‘bitcoin’).- For EVM:
to
,data
,value
,from
,gasPrice
,gasLimit
,chainId
. - For Solana:
data
. - For Bitcoin:
to
,data
,value
.
chainId
(string | number
): The chain ID where the transaction needs to be signed.requiresSigning
(boolean
): Alwaystrue
for hyperswap, indicating the user must sign the transaction.
-
For hyperswapshift Swaps (provider: 'hyperswapshift'):
shiftId
(string
): hyperswapshift’s unique ID for the shift.depositAddress
(string
): The address where the user needs to deposit thefromToken
.depositMemo
(string
, optional): Memo for the deposit address, if required by the destination.expiresAt
(string
): ISO timestamp when the deposit address expires.type
(string
): Typically ‘hyperswapshift-deposit’.requiresSigning
(boolean
): Alwaysfalse
for hyperswapshift, as it involves a deposit rather than a direct signature.
-
- Error Responses:
400 Bad Request
:{ "message": "provider, settleAddress, and clientId are required" }
{ "message": "Missing required fields for hyperswap swap" }
{ "message": "quoteId is required for hyperswapshift swaps" }
{ "message": "Quote not found or expired. Please generate a new quote." }
{ "message": "The generated hyperswap quote is not valid for execution" }
{ "message": "The cached hyperswapshift quote is no longer valid for execution" }
{ "message": "Unsupported provider" }
500 Internal Server Error
:{ "message": "Failed to execute swap", "error": "An unknown error occurred" }
- Notes:
- For hyperswap, the
refundAddress
might be overridden by environment variables for specific chain types (e.g., Solana, Bitcoin, EVM) to ensure proper handling. - A
Transaction
record is created in the internal database to track the swap’s lifecycle.
- For hyperswap, the
4. Get Transaction Status
GET /api/v1/status/{transactionId}
-
Description: Retrieves the current status of a previously initiated swap transaction using its internal
transactionId
. This endpoint polls the respective liquidity provider for the latest status and updates the internal database. -
Path Parameters:
transactionId
(string
): The unique ID of the transaction, generated by the/api/v1/swap
endpoint.
-
Response (JSON): Returns a
Transaction
object from the internal database.