LaserSell API
Build Sell Transaction
Build an unsigned sell transaction to swap tokens for SOL or USD1 via one of the supported DEXs.
The response contains a base64-encoded unsigned VersionedTransaction. Sign it locally with your keypair and submit it to the network.
POST
/
v1
/
sell
Build Sell Transaction
curl --request POST \
--url https://api.lasersell.io/v1/sell \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"mint": "So11111111111111111111111111111111111111112",
"user_pubkey": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
"amount_tokens": 1000000,
"output": "SOL",
"slippage_bps": 2000,
"mode": "fast",
"market_context": {},
"tip_lamports": 123,
"partner_fee_recipient": "<string>",
"partner_fee_bps": 49,
"partner_fee_lamports": 123
}
'import requests
url = "https://api.lasersell.io/v1/sell"
payload = {
"mint": "So11111111111111111111111111111111111111112",
"user_pubkey": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
"amount_tokens": 1000000,
"output": "SOL",
"slippage_bps": 2000,
"mode": "fast",
"market_context": {},
"tip_lamports": 123,
"partner_fee_recipient": "<string>",
"partner_fee_bps": 49,
"partner_fee_lamports": 123
}
headers = {
"x-api-key": "<api-key>",
"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>', 'Content-Type': 'application/json'},
body: JSON.stringify({
mint: 'So11111111111111111111111111111111111111112',
user_pubkey: '9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM',
amount_tokens: 1000000,
output: 'SOL',
slippage_bps: 2000,
mode: 'fast',
market_context: {},
tip_lamports: 123,
partner_fee_recipient: '<string>',
partner_fee_bps: 49,
partner_fee_lamports: 123
})
};
fetch('https://api.lasersell.io/v1/sell', 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://api.lasersell.io/v1/sell",
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([
'mint' => 'So11111111111111111111111111111111111111112',
'user_pubkey' => '9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM',
'amount_tokens' => 1000000,
'output' => 'SOL',
'slippage_bps' => 2000,
'mode' => 'fast',
'market_context' => [
],
'tip_lamports' => 123,
'partner_fee_recipient' => '<string>',
'partner_fee_bps' => 49,
'partner_fee_lamports' => 123
]),
CURLOPT_HTTPHEADER => [
"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://api.lasersell.io/v1/sell"
payload := strings.NewReader("{\n \"mint\": \"So11111111111111111111111111111111111111112\",\n \"user_pubkey\": \"9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM\",\n \"amount_tokens\": 1000000,\n \"output\": \"SOL\",\n \"slippage_bps\": 2000,\n \"mode\": \"fast\",\n \"market_context\": {},\n \"tip_lamports\": 123,\n \"partner_fee_recipient\": \"<string>\",\n \"partner_fee_bps\": 49,\n \"partner_fee_lamports\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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://api.lasersell.io/v1/sell")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"mint\": \"So11111111111111111111111111111111111111112\",\n \"user_pubkey\": \"9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM\",\n \"amount_tokens\": 1000000,\n \"output\": \"SOL\",\n \"slippage_bps\": 2000,\n \"mode\": \"fast\",\n \"market_context\": {},\n \"tip_lamports\": 123,\n \"partner_fee_recipient\": \"<string>\",\n \"partner_fee_bps\": 49,\n \"partner_fee_lamports\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lasersell.io/v1/sell")
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["Content-Type"] = 'application/json'
request.body = "{\n \"mint\": \"So11111111111111111111111111111111111111112\",\n \"user_pubkey\": \"9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM\",\n \"amount_tokens\": 1000000,\n \"output\": \"SOL\",\n \"slippage_bps\": 2000,\n \"mode\": \"fast\",\n \"market_context\": {},\n \"tip_lamports\": 123,\n \"partner_fee_recipient\": \"<string>\",\n \"partner_fee_bps\": 49,\n \"partner_fee_lamports\": 123\n}"
response = http.request(request)
puts response.read_body{
"tx": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...",
"route": {
"market_type": "pumpswap",
"pool_id": "<string>"
},
"debug": {}
}{
"error": "invalid mint address"
}{
"error": "invalid mint address"
}{
"status": "unsupported",
"reason": "no_route",
"message": "No supported market found for this mint. Supported DEXs: PumpSwap, Raydium (CPMM, Launchpad), Meteora (DBC, DAMM v2), Pump.fun."
}{
"error": "invalid mint address"
}{
"error": "invalid mint address"
}{
"error": "invalid mint address"
}SDK Examples
import { ExitApiClient, type BuildSellTxRequest } from "@lasersell/lasersell-sdk";
const client = ExitApiClient.withApiKey("YOUR_API_KEY");
const request: BuildSellTxRequest = {
mint: "TOKEN_MINT_ADDRESS",
user_pubkey: "YOUR_WALLET_PUBKEY",
amount_tokens: 1_000_000,
slippage_bps: 2_000,
output: "SOL",
};
const response = await client.buildSellTx(request);
console.log("Unsigned tx (base64):", response.tx);
// Or get just the base64 string:
const txB64 = await client.buildSellTxB64(request);
from lasersell_sdk.exit_api import ExitApiClient, BuildSellTxRequest, SellOutput
client = ExitApiClient.with_api_key("YOUR_API_KEY")
request = BuildSellTxRequest(
mint="TOKEN_MINT_ADDRESS",
user_pubkey="YOUR_WALLET_PUBKEY",
amount_tokens=1_000_000,
slippage_bps=2_000,
output=SellOutput.SOL,
)
response = await client.build_sell_tx(request)
print("Unsigned tx (base64):", response.tx)
use lasersell_sdk::exit_api::{ExitApiClient, BuildSellTxRequest, SellOutput};
let client = ExitApiClient::with_api_key("YOUR_API_KEY");
let request = BuildSellTxRequest {
mint: "TOKEN_MINT_ADDRESS".into(),
user_pubkey: "YOUR_WALLET_PUBKEY".into(),
amount_tokens: 1_000_000,
output: SellOutput::Sol,
slippage_bps: 2_000,
..Default::default()
};
let response = client.build_sell_tx(&request).await?;
println!("Unsigned tx (base64): {}", response.tx);
import lasersell "github.com/lasersell/lasersell-sdk/go"
client := lasersell.NewExitAPIClientWithAPIKey("YOUR_API_KEY")
resp, err := client.BuildSellTx(ctx, lasersell.BuildSellTxRequest{
Mint: "TOKEN_MINT_ADDRESS",
UserPubkey: "YOUR_WALLET_PUBKEY",
AmountTokens: 1_000_000,
Output: lasersell.SellOutputSOL,
SlippageBps: 2_000,
})
if err != nil {
log.Fatal(err)
}
fmt.Println("Unsigned tx (base64):", resp.Tx)
Error Responses
See Error Handling for the full error envelope specification and retryable error logic.Authorizations
Your LaserSell API key. Obtain one from the LaserSell dashboard.
Body
application/json
Response
Unsigned sell transaction built successfully.
⌘I
Build Sell Transaction
curl --request POST \
--url https://api.lasersell.io/v1/sell \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"mint": "So11111111111111111111111111111111111111112",
"user_pubkey": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
"amount_tokens": 1000000,
"output": "SOL",
"slippage_bps": 2000,
"mode": "fast",
"market_context": {},
"tip_lamports": 123,
"partner_fee_recipient": "<string>",
"partner_fee_bps": 49,
"partner_fee_lamports": 123
}
'import requests
url = "https://api.lasersell.io/v1/sell"
payload = {
"mint": "So11111111111111111111111111111111111111112",
"user_pubkey": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
"amount_tokens": 1000000,
"output": "SOL",
"slippage_bps": 2000,
"mode": "fast",
"market_context": {},
"tip_lamports": 123,
"partner_fee_recipient": "<string>",
"partner_fee_bps": 49,
"partner_fee_lamports": 123
}
headers = {
"x-api-key": "<api-key>",
"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>', 'Content-Type': 'application/json'},
body: JSON.stringify({
mint: 'So11111111111111111111111111111111111111112',
user_pubkey: '9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM',
amount_tokens: 1000000,
output: 'SOL',
slippage_bps: 2000,
mode: 'fast',
market_context: {},
tip_lamports: 123,
partner_fee_recipient: '<string>',
partner_fee_bps: 49,
partner_fee_lamports: 123
})
};
fetch('https://api.lasersell.io/v1/sell', 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://api.lasersell.io/v1/sell",
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([
'mint' => 'So11111111111111111111111111111111111111112',
'user_pubkey' => '9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM',
'amount_tokens' => 1000000,
'output' => 'SOL',
'slippage_bps' => 2000,
'mode' => 'fast',
'market_context' => [
],
'tip_lamports' => 123,
'partner_fee_recipient' => '<string>',
'partner_fee_bps' => 49,
'partner_fee_lamports' => 123
]),
CURLOPT_HTTPHEADER => [
"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://api.lasersell.io/v1/sell"
payload := strings.NewReader("{\n \"mint\": \"So11111111111111111111111111111111111111112\",\n \"user_pubkey\": \"9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM\",\n \"amount_tokens\": 1000000,\n \"output\": \"SOL\",\n \"slippage_bps\": 2000,\n \"mode\": \"fast\",\n \"market_context\": {},\n \"tip_lamports\": 123,\n \"partner_fee_recipient\": \"<string>\",\n \"partner_fee_bps\": 49,\n \"partner_fee_lamports\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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://api.lasersell.io/v1/sell")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"mint\": \"So11111111111111111111111111111111111111112\",\n \"user_pubkey\": \"9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM\",\n \"amount_tokens\": 1000000,\n \"output\": \"SOL\",\n \"slippage_bps\": 2000,\n \"mode\": \"fast\",\n \"market_context\": {},\n \"tip_lamports\": 123,\n \"partner_fee_recipient\": \"<string>\",\n \"partner_fee_bps\": 49,\n \"partner_fee_lamports\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lasersell.io/v1/sell")
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["Content-Type"] = 'application/json'
request.body = "{\n \"mint\": \"So11111111111111111111111111111111111111112\",\n \"user_pubkey\": \"9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM\",\n \"amount_tokens\": 1000000,\n \"output\": \"SOL\",\n \"slippage_bps\": 2000,\n \"mode\": \"fast\",\n \"market_context\": {},\n \"tip_lamports\": 123,\n \"partner_fee_recipient\": \"<string>\",\n \"partner_fee_bps\": 49,\n \"partner_fee_lamports\": 123\n}"
response = http.request(request)
puts response.read_body{
"tx": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...",
"route": {
"market_type": "pumpswap",
"pool_id": "<string>"
},
"debug": {}
}{
"error": "invalid mint address"
}{
"error": "invalid mint address"
}{
"status": "unsupported",
"reason": "no_route",
"message": "No supported market found for this mint. Supported DEXs: PumpSwap, Raydium (CPMM, Launchpad), Meteora (DBC, DAMM v2), Pump.fun."
}{
"error": "invalid mint address"
}{
"error": "invalid mint address"
}{
"error": "invalid mint address"
}
