api-pump.fun
  • General
    • Getting started
  • Reference
    • API Reference
      • Generate API Key
      • Balance
      • Token information
      • Get Quote
      • Bonding Curve
      • King of The Hill
      • Trade tokens
      • Trade tokens [local RPC]
      • Create token
  • Streams
    • Websocket subscription
Powered by GitBook
On this page
  1. Reference
  2. API Reference

Trade tokens [local RPC]

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

Name
Value

Content-Type

application/json

x-api-key

The API key for authentication

Parameters

Parameter
Description
Required

mode

Mode of the trade (e.g., “buy”, “sell”)

Yes

token

Token to be traded

Yes

amount

Amount of the token to trade (lamports)

Yes

amountInSol

Boolean indicating if amount is in SOL

Yes

slippage

Allowed slippage percentage (basis points)

Yes

priorityFee

Priority fee for the transaction (microlamports)

Yes

public

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)
PreviousTrade tokensNextCreate token

Last updated 10 months ago