PumpSwapApi - HTTP API for Pump.funPumpSwapApi - HTTP API for Pump.fun
Telegram
Telegram
  • Welcome

    • What is PumpSwapApi?
  • Local Transaction API

    • Trade
    • Create token
  • Fees
  • Legal

Local Transaction API

The Local Transaction API builds a transaction that you handle signing and sending yourself with a custom RPC endpoint. This gives you full security and control over your transactions.

Benefits

  • Complete control over transaction signing
  • Use your own RPC endpoint
  • Higher security for sensitive operations
  • Full transaction customization

API Endpoints

Build Trading Transaction

POST https://pumpswapapi.fun/api/trade/trade-local

Generates an unsigned transaction for buying or selling tokens.

Request Parameters

ParameterTypeRequiredDescription
publicKeystringYesThe public key of your wallet
actionstringYesTrade action: 'buy' or 'sell'
mintstringYesToken address/mint
amountstringYesAmount to trade (can include % for sell)
amountTypestringYes'sol' for buy operations, 'token' for sell operations
poolstringYesTrading pool to use: 'pumpfun' or 'pumpswap'
slippagenumberNoSlippage tolerance in percent (default: 1)
priorityFeenumberNoPriority fee in SOL (default: 0.0001)

Response

{
  "transaction": "base64EncodedSerializedTransaction"
}

Example

const axios = require('axios');
const web3 = require('@solana/web3.js');

async function buildAndSendTransaction() {
  try {
    // 1. Build the transaction using the PumpSwapApi API
    const response = await axios.post('https://pumpswapapi.fun/api/trade/trade-local', {
      publicKey: 'YOUR_WALLET_ADDRESS',
      action: 'buy',
      mint: '91WNez8D22NwBssQbkzjy4s2ipFrzpmn5hfvWVe2aY5p',
      amount: '0.1',
      amountType: 'sol',
      pool: 'pumpfun',
      slippage: 1,
      priorityFee: 0.0001
    });
    
    const { transaction: serializedTransaction } = response.data;
    
    // 2. Deserialize the transaction (for Versioned Transactions)
    const transaction = web3.VersionedTransaction.deserialize(
      Buffer.from(serializedTransaction, 'base64')
    );
    
    // 3. Connect to your preferred RPC endpoint
    const connection = new web3.Connection('YOUR_RPC_ENDPOINT', 'confirmed');
    
    // 4. Sign the transaction with your wallet
    const wallet = web3.Keypair.fromSecretKey(YOUR_PRIVATE_KEY);
    transaction.sign([wallet]);
    
    // 5. Send the transaction
    const signature = await connection.sendTransaction(transaction);
    
    console.log('Transaction sent:', signature);
    
    // 6. Wait for confirmation
    await connection.confirmTransaction(signature, 'confirmed');
    
    console.log('Transaction confirmed!');
  } catch (error) {
    console.error('Error:', error.message);
    if (error.response) {
      console.error('API Error:', error.response.data);
    }
  }
}

buildAndSendTransaction();

Selling Tokens - Using Percentage

When selling tokens, you can specify a percentage amount by including a '%' symbol:

// Sell 50% of your token balance
const response = await axios.post('https://pumpswapapi.fun/api/trade/trade-local', {
  publicKey: 'YOUR_WALLET_ADDRESS',
  action: 'sell',
  mint: '91WNez8D22NwBssQbkzjy4s2ipFrzpmn5hfvWVe2aY5p',
  amount: '50%',
  amountType: 'token',
  pool: 'pumpfun'
});

Possible Errors

Error CodeMessageDescription
400Missing required parametersOne or more required parameters are missing
400Sell action only supports token amountsFor 'sell' actions, amountType must be 'token'
400Buy action only supports SOL amountsFor 'buy' actions, amountType must be 'sol'
400Invalid amount valueAmount is not a valid number or percentage
400Amount is too small. Minimum is 0.000001 SOLBuy amount is below minimum
400Amount is too small. Minimum is 1 tokenSell amount is below minimum
400Unsupported trading poolThe specified pool is not valid
400Invalid percentage value. Must be between 0 and 100For percentage sells, value must be 0-100
500Failed to process trade requestGeneric server error

Security Considerations

When using the PumpSwapApi Local Transaction API, you maintain control of your private keys at all times. The API only builds the transaction, which you then sign and send yourself. This provides an additional layer of security for sensitive operations.

Next
Create token