To get a buy or sell transaction that you can self sign and send using your RPC for Pump.fun tokens, send a POST request to:

Note:

If you just need to skip this complex process & just place a buy/sell use Trade API endpoint instead.

Endpoint URL: https://pumpapi.fun/api/trade_transaction

Your request body must contain the following Parameters:

ParameterExampleDescriptionRequired
trade_typeBuy or sell”buy” or “sell” to specify trade typeYes
mintToken mint addressToken mint addressYes
amountValue in of SOL/TokensAmount of SOL or tokens to tradeYes
slippageDesired slippageSlippage allowed (integer)Yes
priorityFeeValue in SOL (optional)Amount to use as priority fee (optional) In SOLNo
userPublicKeyUser wallet addressThe wallet used the sign the transactionYes

Accepted Parameters:

The API accepts all parameters listed in the table above.

Note Amount in SOL , if buying or of tokens if selling.

Examples Usage:

Response Type:

The API returns JSON data upon successful execution:

{

  "transaction": "2wJWJW4Ln7N5EA8WnThaq4m4tgH6TPxcPYMP9ZN1VhyDEtpszCnwXcJd2qFPPfpH1n5Cgc6x2CHeWZctFLzi63mcmJwwkMJmtJskAAqKxnZj1tCX5jUrpvKBoPtLPgGS5vCtQRbnJu17r1GaaXpFfwNdfYZW7whbewdwA6oLUpszKA8JSs9tjtQz6j2aEjmDC2DE6Kd2PV2DwzTjEi5Gp15oZjqbHVp7U8GDeM972kJgLfE1CbZzuXZoEQQcCvykF9E6NcS3jNnAHzZhN8bPzaDMfmTYpyRLSrAPXLSARGPxqMorVs1QRzHLcnkZy9mR5x...."

}

The transaction object is a base58 encoded transaction which later you can sign and send it as per your needs.

Below shows how to do this:

const transaction = VersionedTransaction.deserialize(bs58.decode(data['transaction']));

console.log(transaction);


Now below is the complete snippet to sign and send the transaction:

Typescript
import { VersionedTransaction } from "@solana/web3.js";

import bs58 from "bs58";



//....



const data: any = await response.json(); // Parse JSON response 



const transaction = VersionedTransaction.deserialize(bs58.decode(data['transaction']));

console.log(transaction);



transaction.sign([owner.payer]);  // Tx feepayer 

console.log("Transaction loaded and signed...");



const txid = await connection.sendTransaction(transaction, {

    skipPreflight: false,

    maxRetries: 2,

});

console.log(`https://solscan.io/tx/${txid}`);


Error Codes

  • 400 Bad Request: Invalid request parameters or missing required fields.
  • 401 Unauthorized: Authentication failed.
  • 404 Not Found: The requested resource (endpoint) is not found.
  • 429 Too Many Requests: Rate limit exceeded.
  • 500 Internal Server Error: Unexpected server-side error.

API Codes

  • 200 OK: The request was successful.