Get perp quote
curl --request POST \
--url https://demo-api.mobula.io/api/2/perp/quote \
--header 'Content-Type: application/json' \
--data '
{
"user": "<string>",
"baseToken": "<string>",
"quote": "<string>",
"leverage": 123,
"long": true,
"reduceOnly": true,
"collateralAmount": 123,
"openPrice": 123,
"tp": 123,
"sl": 123,
"amountRaw": 123,
"maxSlippageP": 123,
"chainIds": [
"<string>"
],
"dexes": [],
"marginMode": 123,
"referrer": "<string>"
}
'import requests
url = "https://demo-api.mobula.io/api/2/perp/quote"
payload = {
"user": "<string>",
"baseToken": "<string>",
"quote": "<string>",
"leverage": 123,
"long": True,
"reduceOnly": True,
"collateralAmount": 123,
"openPrice": 123,
"tp": 123,
"sl": 123,
"amountRaw": 123,
"maxSlippageP": 123,
"chainIds": ["<string>"],
"dexes": [],
"marginMode": 123,
"referrer": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
user: '<string>',
baseToken: '<string>',
quote: '<string>',
leverage: 123,
long: true,
reduceOnly: true,
collateralAmount: 123,
openPrice: 123,
tp: 123,
sl: 123,
amountRaw: 123,
maxSlippageP: 123,
chainIds: ['<string>'],
dexes: [],
marginMode: 123,
referrer: '<string>'
})
};
fetch('https://demo-api.mobula.io/api/2/perp/quote', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://demo-api.mobula.io/api/2/perp/quote",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'user' => '<string>',
'baseToken' => '<string>',
'quote' => '<string>',
'leverage' => 123,
'long' => true,
'reduceOnly' => true,
'collateralAmount' => 123,
'openPrice' => 123,
'tp' => 123,
'sl' => 123,
'amountRaw' => 123,
'maxSlippageP' => 123,
'chainIds' => [
'<string>'
],
'dexes' => [
],
'marginMode' => 123,
'referrer' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://demo-api.mobula.io/api/2/perp/quote"
payload := strings.NewReader("{\n \"user\": \"<string>\",\n \"baseToken\": \"<string>\",\n \"quote\": \"<string>\",\n \"leverage\": 123,\n \"long\": true,\n \"reduceOnly\": true,\n \"collateralAmount\": 123,\n \"openPrice\": 123,\n \"tp\": 123,\n \"sl\": 123,\n \"amountRaw\": 123,\n \"maxSlippageP\": 123,\n \"chainIds\": [\n \"<string>\"\n ],\n \"dexes\": [],\n \"marginMode\": 123,\n \"referrer\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://demo-api.mobula.io/api/2/perp/quote")
.header("Content-Type", "application/json")
.body("{\n \"user\": \"<string>\",\n \"baseToken\": \"<string>\",\n \"quote\": \"<string>\",\n \"leverage\": 123,\n \"long\": true,\n \"reduceOnly\": true,\n \"collateralAmount\": 123,\n \"openPrice\": 123,\n \"tp\": 123,\n \"sl\": 123,\n \"amountRaw\": 123,\n \"maxSlippageP\": 123,\n \"chainIds\": [\n \"<string>\"\n ],\n \"dexes\": [],\n \"marginMode\": 123,\n \"referrer\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://demo-api.mobula.io/api/2/perp/quote")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"user\": \"<string>\",\n \"baseToken\": \"<string>\",\n \"quote\": \"<string>\",\n \"leverage\": 123,\n \"long\": true,\n \"reduceOnly\": true,\n \"collateralAmount\": 123,\n \"openPrice\": 123,\n \"tp\": 123,\n \"sl\": 123,\n \"amountRaw\": 123,\n \"maxSlippageP\": 123,\n \"chainIds\": [\n \"<string>\"\n ],\n \"dexes\": [],\n \"marginMode\": 123,\n \"referrer\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"dex": "<string>",
"marketId": "<string>",
"chainId": "<string>",
"payload": {},
"payloadStr": "<string>"
}
}Execution
Get Perp Quote
Get a non-binding quote for opening a perpetual position on a supported DEX (Gains Network, Lighter). Quotes do not authenticate the caller and are not used by the execution flow; they are purely informational and exposed to help clients pick a DEX, price, or slippage before building a real payload.
POST
/
2
/
perp
/
quote
Get perp quote
curl --request POST \
--url https://demo-api.mobula.io/api/2/perp/quote \
--header 'Content-Type: application/json' \
--data '
{
"user": "<string>",
"baseToken": "<string>",
"quote": "<string>",
"leverage": 123,
"long": true,
"reduceOnly": true,
"collateralAmount": 123,
"openPrice": 123,
"tp": 123,
"sl": 123,
"amountRaw": 123,
"maxSlippageP": 123,
"chainIds": [
"<string>"
],
"dexes": [],
"marginMode": 123,
"referrer": "<string>"
}
'import requests
url = "https://demo-api.mobula.io/api/2/perp/quote"
payload = {
"user": "<string>",
"baseToken": "<string>",
"quote": "<string>",
"leverage": 123,
"long": True,
"reduceOnly": True,
"collateralAmount": 123,
"openPrice": 123,
"tp": 123,
"sl": 123,
"amountRaw": 123,
"maxSlippageP": 123,
"chainIds": ["<string>"],
"dexes": [],
"marginMode": 123,
"referrer": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
user: '<string>',
baseToken: '<string>',
quote: '<string>',
leverage: 123,
long: true,
reduceOnly: true,
collateralAmount: 123,
openPrice: 123,
tp: 123,
sl: 123,
amountRaw: 123,
maxSlippageP: 123,
chainIds: ['<string>'],
dexes: [],
marginMode: 123,
referrer: '<string>'
})
};
fetch('https://demo-api.mobula.io/api/2/perp/quote', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://demo-api.mobula.io/api/2/perp/quote",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'user' => '<string>',
'baseToken' => '<string>',
'quote' => '<string>',
'leverage' => 123,
'long' => true,
'reduceOnly' => true,
'collateralAmount' => 123,
'openPrice' => 123,
'tp' => 123,
'sl' => 123,
'amountRaw' => 123,
'maxSlippageP' => 123,
'chainIds' => [
'<string>'
],
'dexes' => [
],
'marginMode' => 123,
'referrer' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://demo-api.mobula.io/api/2/perp/quote"
payload := strings.NewReader("{\n \"user\": \"<string>\",\n \"baseToken\": \"<string>\",\n \"quote\": \"<string>\",\n \"leverage\": 123,\n \"long\": true,\n \"reduceOnly\": true,\n \"collateralAmount\": 123,\n \"openPrice\": 123,\n \"tp\": 123,\n \"sl\": 123,\n \"amountRaw\": 123,\n \"maxSlippageP\": 123,\n \"chainIds\": [\n \"<string>\"\n ],\n \"dexes\": [],\n \"marginMode\": 123,\n \"referrer\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://demo-api.mobula.io/api/2/perp/quote")
.header("Content-Type", "application/json")
.body("{\n \"user\": \"<string>\",\n \"baseToken\": \"<string>\",\n \"quote\": \"<string>\",\n \"leverage\": 123,\n \"long\": true,\n \"reduceOnly\": true,\n \"collateralAmount\": 123,\n \"openPrice\": 123,\n \"tp\": 123,\n \"sl\": 123,\n \"amountRaw\": 123,\n \"maxSlippageP\": 123,\n \"chainIds\": [\n \"<string>\"\n ],\n \"dexes\": [],\n \"marginMode\": 123,\n \"referrer\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://demo-api.mobula.io/api/2/perp/quote")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"user\": \"<string>\",\n \"baseToken\": \"<string>\",\n \"quote\": \"<string>\",\n \"leverage\": 123,\n \"long\": true,\n \"reduceOnly\": true,\n \"collateralAmount\": 123,\n \"openPrice\": 123,\n \"tp\": 123,\n \"sl\": 123,\n \"amountRaw\": 123,\n \"maxSlippageP\": 123,\n \"chainIds\": [\n \"<string>\"\n ],\n \"dexes\": [],\n \"marginMode\": 123,\n \"referrer\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"dex": "<string>",
"marketId": "<string>",
"chainId": "<string>",
"payload": {},
"payloadStr": "<string>"
}
}Quotes are informational only. Execution uses the
/2/perp/payloads/<action> → /2/perp/execute-v2 flow. Use the quote endpoint to preview fills, fees, and which DEX would route best; then call /2/perp/payloads/create-order to build the actual signed payload you submit.Request Body
Wallet address of the trader. Used to scope the quote (e.g., Lighter account lookup).
Quote is unauthenticated. Unlike the payload endpoints,
/2/perp/quote does not take a signature field — only user is required. The quote endpoint is purely informational; nothing is signed or executed.Quote token of the market. Semantics differ per DEX:
- Lighter — pass the ERC-20 collateral symbol (
USDC). - Gains — pass the synthetic quote (
USD).
marketId (e.g. gains-btc-usd, lighter-btc-usd) — the field is derived server-side from the market.Routing hint, not a strict filter. If the matching market is not deployed on any of the requested chains, the router falls back to a chain that hosts it (e.g.
chainIds: ['evm:42161'] for a Base-only market silently returns chainId: 'evm:8453'). Always trust the response chainId. Omit to search all supported chains.Response
Show data
Show data
Informational payload structure for the matched DEX. Not the payload used for execution — to execute, call
/2/perp/payloads/create-order with the same parameters.Show Lighter payload
Show Lighter payload
Errors
| Status | When | message |
|---|---|---|
| 400 | Zod validation failed | zod validation failed |
| 500 | No DEX returned a quote | could not find quote |
errors field lists per-DEX failures, formatted as "<dex> - <error>".Body
application/json