Skip to main content

Buy a token

The PumpFunAPI class provides quickBuyToken function to buy a token on pump.fun instantly without any timeouts.

quickBuyToken(buyer, tokenAddresses, buyAmount)

Parameters

buyer (string): Buyer's private key.

tokenAddresses (string): token addresses.

buyAmount (number): Amount to buy.

How to buy a token on pump.fun using api?

the below example will show how to buy a token using pumpfunapi.xyz

const PumpFunAPI = require('pumpfunapi.xyz');
const client = new PumpFunAPI('https://api.mainnet-beta.solana.com', 'your-private-key');
//private key mentioned in client is only used to pay fees of the api
//keep this wallet loaded with sol. fee of 0.002 SOL will be deducted after successfull execution


client.quickBuyToken(
'buyer-private-key',
'token-address',
"0.04" //buy amount in sol
);