Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
curl --request POST \
--url https://swap-api.flux.fun/v1/order \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"orderType": "MarketOrder",
"order": {
"quoteToken": {
"type": "kalshi",
"data": {
"marketId": "KXBTC-24NOV30-T65000",
"side": "yes"
}
},
"baseToken": {
"type": "kalshi",
"data": {
"marketId": "KXBTC-24NOV30-T65000",
"side": "yes"
}
},
"orderType": "BUY",
"baseQuantity": "100",
"minQuoteQuantityOut": "95",
"maxQuoteQuantityIn": "105"
},
"chainId": 8453,
"clientId": "order-123",
"includeTokenTransfer": false,
"userAddress": "0x...",
"receiverAddress": "0x..."
}
'import requests
url = "https://swap-api.flux.fun/v1/order"
payload = {
"orderType": "MarketOrder",
"order": {
"quoteToken": {
"type": "kalshi",
"data": {
"marketId": "KXBTC-24NOV30-T65000",
"side": "yes"
}
},
"baseToken": {
"type": "kalshi",
"data": {
"marketId": "KXBTC-24NOV30-T65000",
"side": "yes"
}
},
"orderType": "BUY",
"baseQuantity": "100",
"minQuoteQuantityOut": "95",
"maxQuoteQuantityIn": "105"
},
"chainId": 8453,
"clientId": "order-123",
"includeTokenTransfer": False,
"userAddress": "0x...",
"receiverAddress": "0x..."
}
headers = {
"x-api-key": "<api-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-api-key': '<api-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
orderType: 'MarketOrder',
order: {
quoteToken: {type: 'kalshi', data: {marketId: 'KXBTC-24NOV30-T65000', side: 'yes'}},
baseToken: {type: 'kalshi', data: {marketId: 'KXBTC-24NOV30-T65000', side: 'yes'}},
orderType: 'BUY',
baseQuantity: '100',
minQuoteQuantityOut: '95',
maxQuoteQuantityIn: '105'
},
chainId: 8453,
clientId: 'order-123',
includeTokenTransfer: false,
userAddress: '0x...',
receiverAddress: '0x...'
})
};
fetch('https://swap-api.flux.fun/v1/order', 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://swap-api.flux.fun/v1/order",
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([
'orderType' => 'MarketOrder',
'order' => [
'quoteToken' => [
'type' => 'kalshi',
'data' => [
'marketId' => 'KXBTC-24NOV30-T65000',
'side' => 'yes'
]
],
'baseToken' => [
'type' => 'kalshi',
'data' => [
'marketId' => 'KXBTC-24NOV30-T65000',
'side' => 'yes'
]
],
'orderType' => 'BUY',
'baseQuantity' => '100',
'minQuoteQuantityOut' => '95',
'maxQuoteQuantityIn' => '105'
],
'chainId' => 8453,
'clientId' => 'order-123',
'includeTokenTransfer' => false,
'userAddress' => '0x...',
'receiverAddress' => '0x...'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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://swap-api.flux.fun/v1/order"
payload := strings.NewReader("{\n \"orderType\": \"MarketOrder\",\n \"order\": {\n \"quoteToken\": {\n \"type\": \"kalshi\",\n \"data\": {\n \"marketId\": \"KXBTC-24NOV30-T65000\",\n \"side\": \"yes\"\n }\n },\n \"baseToken\": {\n \"type\": \"kalshi\",\n \"data\": {\n \"marketId\": \"KXBTC-24NOV30-T65000\",\n \"side\": \"yes\"\n }\n },\n \"orderType\": \"BUY\",\n \"baseQuantity\": \"100\",\n \"minQuoteQuantityOut\": \"95\",\n \"maxQuoteQuantityIn\": \"105\"\n },\n \"chainId\": 8453,\n \"clientId\": \"order-123\",\n \"includeTokenTransfer\": false,\n \"userAddress\": \"0x...\",\n \"receiverAddress\": \"0x...\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Authorization", "Bearer <token>")
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://swap-api.flux.fun/v1/order")
.header("x-api-key", "<api-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"orderType\": \"MarketOrder\",\n \"order\": {\n \"quoteToken\": {\n \"type\": \"kalshi\",\n \"data\": {\n \"marketId\": \"KXBTC-24NOV30-T65000\",\n \"side\": \"yes\"\n }\n },\n \"baseToken\": {\n \"type\": \"kalshi\",\n \"data\": {\n \"marketId\": \"KXBTC-24NOV30-T65000\",\n \"side\": \"yes\"\n }\n },\n \"orderType\": \"BUY\",\n \"baseQuantity\": \"100\",\n \"minQuoteQuantityOut\": \"95\",\n \"maxQuoteQuantityIn\": \"105\"\n },\n \"chainId\": 8453,\n \"clientId\": \"order-123\",\n \"includeTokenTransfer\": false,\n \"userAddress\": \"0x...\",\n \"receiverAddress\": \"0x...\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://swap-api.flux.fun/v1/order")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"orderType\": \"MarketOrder\",\n \"order\": {\n \"quoteToken\": {\n \"type\": \"kalshi\",\n \"data\": {\n \"marketId\": \"KXBTC-24NOV30-T65000\",\n \"side\": \"yes\"\n }\n },\n \"baseToken\": {\n \"type\": \"kalshi\",\n \"data\": {\n \"marketId\": \"KXBTC-24NOV30-T65000\",\n \"side\": \"yes\"\n }\n },\n \"orderType\": \"BUY\",\n \"baseQuantity\": \"100\",\n \"minQuoteQuantityOut\": \"95\",\n \"maxQuoteQuantityIn\": \"105\"\n },\n \"chainId\": 8453,\n \"clientId\": \"order-123\",\n \"includeTokenTransfer\": false,\n \"userAddress\": \"0x...\",\n \"receiverAddress\": \"0x...\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"intent": {
"id": "intent_abc123xyz",
"clientId": "client-order-123",
"action": {
"orderType": "MarketOrder",
"order": {
"quoteToken": {
"type": "chain",
"data": {
"tokenId": "USDC",
"chainId": 8453,
"contractAddress": "0x..."
}
},
"baseToken": {
"type": "kalshi",
"data": {
"marketId": "BTC-100K-2024",
"side": "yes"
}
},
"orderType": "BUY",
"baseQuantity": "100",
"maxQuoteQuantityIn": "50.00"
},
"chainId": 8453
},
"createdAt": "2024-01-12T10:00:00.000Z"
}
}Create a new market order for trading between prediction market tokens and on-chain tokens. The order will be processed asynchronously through multiple stages: balance validation, placement on the prediction market, fill detection, and on-chain execution.
curl --request POST \
--url https://swap-api.flux.fun/v1/order \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"orderType": "MarketOrder",
"order": {
"quoteToken": {
"type": "kalshi",
"data": {
"marketId": "KXBTC-24NOV30-T65000",
"side": "yes"
}
},
"baseToken": {
"type": "kalshi",
"data": {
"marketId": "KXBTC-24NOV30-T65000",
"side": "yes"
}
},
"orderType": "BUY",
"baseQuantity": "100",
"minQuoteQuantityOut": "95",
"maxQuoteQuantityIn": "105"
},
"chainId": 8453,
"clientId": "order-123",
"includeTokenTransfer": false,
"userAddress": "0x...",
"receiverAddress": "0x..."
}
'import requests
url = "https://swap-api.flux.fun/v1/order"
payload = {
"orderType": "MarketOrder",
"order": {
"quoteToken": {
"type": "kalshi",
"data": {
"marketId": "KXBTC-24NOV30-T65000",
"side": "yes"
}
},
"baseToken": {
"type": "kalshi",
"data": {
"marketId": "KXBTC-24NOV30-T65000",
"side": "yes"
}
},
"orderType": "BUY",
"baseQuantity": "100",
"minQuoteQuantityOut": "95",
"maxQuoteQuantityIn": "105"
},
"chainId": 8453,
"clientId": "order-123",
"includeTokenTransfer": False,
"userAddress": "0x...",
"receiverAddress": "0x..."
}
headers = {
"x-api-key": "<api-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-api-key': '<api-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
orderType: 'MarketOrder',
order: {
quoteToken: {type: 'kalshi', data: {marketId: 'KXBTC-24NOV30-T65000', side: 'yes'}},
baseToken: {type: 'kalshi', data: {marketId: 'KXBTC-24NOV30-T65000', side: 'yes'}},
orderType: 'BUY',
baseQuantity: '100',
minQuoteQuantityOut: '95',
maxQuoteQuantityIn: '105'
},
chainId: 8453,
clientId: 'order-123',
includeTokenTransfer: false,
userAddress: '0x...',
receiverAddress: '0x...'
})
};
fetch('https://swap-api.flux.fun/v1/order', 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://swap-api.flux.fun/v1/order",
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([
'orderType' => 'MarketOrder',
'order' => [
'quoteToken' => [
'type' => 'kalshi',
'data' => [
'marketId' => 'KXBTC-24NOV30-T65000',
'side' => 'yes'
]
],
'baseToken' => [
'type' => 'kalshi',
'data' => [
'marketId' => 'KXBTC-24NOV30-T65000',
'side' => 'yes'
]
],
'orderType' => 'BUY',
'baseQuantity' => '100',
'minQuoteQuantityOut' => '95',
'maxQuoteQuantityIn' => '105'
],
'chainId' => 8453,
'clientId' => 'order-123',
'includeTokenTransfer' => false,
'userAddress' => '0x...',
'receiverAddress' => '0x...'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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://swap-api.flux.fun/v1/order"
payload := strings.NewReader("{\n \"orderType\": \"MarketOrder\",\n \"order\": {\n \"quoteToken\": {\n \"type\": \"kalshi\",\n \"data\": {\n \"marketId\": \"KXBTC-24NOV30-T65000\",\n \"side\": \"yes\"\n }\n },\n \"baseToken\": {\n \"type\": \"kalshi\",\n \"data\": {\n \"marketId\": \"KXBTC-24NOV30-T65000\",\n \"side\": \"yes\"\n }\n },\n \"orderType\": \"BUY\",\n \"baseQuantity\": \"100\",\n \"minQuoteQuantityOut\": \"95\",\n \"maxQuoteQuantityIn\": \"105\"\n },\n \"chainId\": 8453,\n \"clientId\": \"order-123\",\n \"includeTokenTransfer\": false,\n \"userAddress\": \"0x...\",\n \"receiverAddress\": \"0x...\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Authorization", "Bearer <token>")
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://swap-api.flux.fun/v1/order")
.header("x-api-key", "<api-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"orderType\": \"MarketOrder\",\n \"order\": {\n \"quoteToken\": {\n \"type\": \"kalshi\",\n \"data\": {\n \"marketId\": \"KXBTC-24NOV30-T65000\",\n \"side\": \"yes\"\n }\n },\n \"baseToken\": {\n \"type\": \"kalshi\",\n \"data\": {\n \"marketId\": \"KXBTC-24NOV30-T65000\",\n \"side\": \"yes\"\n }\n },\n \"orderType\": \"BUY\",\n \"baseQuantity\": \"100\",\n \"minQuoteQuantityOut\": \"95\",\n \"maxQuoteQuantityIn\": \"105\"\n },\n \"chainId\": 8453,\n \"clientId\": \"order-123\",\n \"includeTokenTransfer\": false,\n \"userAddress\": \"0x...\",\n \"receiverAddress\": \"0x...\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://swap-api.flux.fun/v1/order")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"orderType\": \"MarketOrder\",\n \"order\": {\n \"quoteToken\": {\n \"type\": \"kalshi\",\n \"data\": {\n \"marketId\": \"KXBTC-24NOV30-T65000\",\n \"side\": \"yes\"\n }\n },\n \"baseToken\": {\n \"type\": \"kalshi\",\n \"data\": {\n \"marketId\": \"KXBTC-24NOV30-T65000\",\n \"side\": \"yes\"\n }\n },\n \"orderType\": \"BUY\",\n \"baseQuantity\": \"100\",\n \"minQuoteQuantityOut\": \"95\",\n \"maxQuoteQuantityIn\": \"105\"\n },\n \"chainId\": 8453,\n \"clientId\": \"order-123\",\n \"includeTokenTransfer\": false,\n \"userAddress\": \"0x...\",\n \"receiverAddress\": \"0x...\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"intent": {
"id": "intent_abc123xyz",
"clientId": "client-order-123",
"action": {
"orderType": "MarketOrder",
"order": {
"quoteToken": {
"type": "chain",
"data": {
"tokenId": "USDC",
"chainId": 8453,
"contractAddress": "0x..."
}
},
"baseToken": {
"type": "kalshi",
"data": {
"marketId": "BTC-100K-2024",
"side": "yes"
}
},
"orderType": "BUY",
"baseQuantity": "100",
"maxQuoteQuantityIn": "50.00"
},
"chainId": 8453
},
"createdAt": "2024-01-12T10:00:00.000Z"
}
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Order type
MarketOrder "MarketOrder"
Market order details
Show child attributes
Chain ID
8453
Client-side order ID
"order-123"
Include token transfer in the order
false
User wallet address
"0x..."
Receiver address for tokens
"0x..."
