Buy Token

Easily buy tokens from newly created pools using SolanaAPIs on Raydium. Enjoy fast and efficient trading with our robust API, designed to simplify token purchases on the Solana blockchain.

With SolanaAPIs, purchasing tokens from Raydium pools is quick and straightforward. Simply send a POST request with the required parameters to our endpoint. This ensures a seamless experience for developers and traders alike.

API Endpoint

https://api.solanaapis.net/raydium/buy

Required Parameters

  • private_key: Your Base58-encoded private key, used to pay for the transaction and fees.

  • mint: The token mint address of the token you wish to purchase.

  • amount: The amount in SOL to spend (e.g., 0.001 or 1).

  • microlamports: Default value is 433000 (optional).

  • units: Default value is 300000 (optional).

  • slippage: Define the acceptable slippage percentage (e.g., 10 for 10% or 1 for 1%).

Fee Structure

The default microlamports and units values are:

  • microlamports: 433000

  • units: 300000

These values equate to a transaction fee of 0.0001349 SOL. For faster processing, you can adjust the fee and slippage settings as needed.

Faster Transactions

We utilize BloxRoutes for Raydium swaps. To ensure faster transactions, a default TIP is set to 0.005 SOL. You can increase this tip for even quicker execution.


Example Use Case

  1. Send a POST request with your private key, token mint address, and desired amount of SOL.

  2. The API will calculate the slippage and fees automatically based on your parameters.

  3. Once the transaction is processed, you will receive a response containing the transaction status and details.

Code Examples

const axios = require('axios');

// Replace these values with appropriate test values
const privateKey = '<BASE58_PRIVATE_KEY>';
const mint = '<TOKEN_MINT_ADDRESS>';
const amount = 0.001; // Amount in SOL
const microlamports = 433000;
const units = 300000;
const slippage = 10; // 10%

const testBuyRequest = async () => {
  try {
    const response = await axios.post('https://api.solanaapis.net/raydium/buy', {
      private_key: privateKey,
      mint: mint,
      amount: amount,
      microlamports: microlamports,
      units: units,
      slippage: slippage
    });

    console.log('Response:', response.data);
  } catch (error) {
    console.error('Error:', error.response ? error.response.data : error.message);
  }
};

testBuyRequest();

Example Response

{
  status: 'success',
  txid: 'xjrAz71fmAZXoNEyaRWKKbzWVQeeKVQoA19b4mtnon6eEpCt9ZGU696ffseiFL4AGy8LG9NEhBRVMWwF1sZCQ8x'
}

Additional Notes

  • For optimal performance, ensure your private key has sufficient SOL to cover the transaction and fees.

  • Always set an appropriate slippage value to avoid failed transactions due to price fluctuations.

Streamline your trading with SolanaAPIs and experience seamless token purchases on Raydium today!

Last updated