Make trade and sign
Method is used to get trade instructions for local RPC signing. It provides unsigned transaction and returns the transaction in base64 format.
POST
/tradeInstructions
Method is used to retrieve the unsigned swap transaction
Headers
The API key for authentication
Parameters
Parameter
Description
Required
Mode of the trade (e.g., “buy”, “sell”)
Amount of the token to trade (lamports)
Boolean indicating if amount is in SOL
Allowed slippage percentage (basis points)
Priority fee for the transaction (microlamports)
Public key of buyer/seller/fee payer
Body
Response
{
"tx": "your_unsigned_transaction"
}
{
"error": true,
"message": "apiKey not found"
}
Examples
curl --location 'https://rpc.api-pump.fun/tradeInstructions' \
--header 'Content-Type: application/json' \
--header 'x-api-key: your_api_key' \
--data '{
"mode": "buy",
"token": token_contract,
"amount": 100000,
"amountInSol": false,
"slippage": 500,
"priorityFee": 100000,
"public": ""
}'
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://rpc.api-pump.fun/tradeInstructions"
method := "POST"
payload := strings.NewReader(`{
"mode": "buy",
"token": token_contract,
"amount": 100000,
"amountInSol": false,
"slippage": 500,
"priorityFee": 100000
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("x-api-key", "your_api_key")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
var https = require('follow-redirects').https;
var fs = require('fs');
var options = {
'method': 'POST',
'hostname': 'rpc.api-pump.fun',
'path': '/tradeInstructions',
'headers': {
'Content-Type': 'application/json',
'x-api-key': 'your_api_key'
},
'maxRedirects': 20
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
var postData = "{\n \"mode\": \"buy\",\n \"token\": token_contract,\n \"amount\": 100000,\n \"amountInSol\": false,\n \"slippage\": 500,\n \"priorityFee\": 100000\n}";
req.write(postData);
req.end();
import requests
import json
url = "https://rpc.api-pump.fun/tradeInstructions"
payload = "{\n \"mode\": \"buy\",\n \"token\": token_contract,\n \"amount\": 100000,\n \"amountInSol\": false,\n \"slippage\": 500,\n \"priorityFee\": 100000\n}"
headers = {
'Content-Type': 'application/json',
'x-api-key': 'your_api_key'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Last updated