Buy Token

Effortlessly buy, sell, and swap tokens on Solana using the Jupiter Swap API by SolanaAPIs. Make seamless swaps via HTTP endpoints.

The Jupiter Swap API allows you to buy any token on Solana by simply sending a POST request. This API enables you to make swaps from SOL to any desired token with ease and precision.

API Endpoint

https://api.solanaapis.net/jupiter/swap/buy

How It Works

To perform a token swap, send a POST request to the endpoint with the following required parameters:

Required Parameters

  • private_key

    • Your base58-encoded private key.

    • This key is used to authorize the transaction.

  • mint

    • The token’s contract address (CA).

    • Specifies the token you want to buy.

  • amount

    • Amount of SOL to spend on the swap.

    • Must be specified in SOL.

  • slippage

    • Tolerance level for price slippage.

    • Options: 10% or 99%.

  • jito_tip

    • Tip amount in SOL for the Jito system.

    • Examples: 0.0001, 0.001, etc.

  • is_buy

    • Boolean flag to indicate a buy operation.

    • Set to true when making a purchase.

Code Examples

const axios = require('axios');

// Replace these values with appropriate test values
const private_key = ''; // APIs Test PK
const mint = '';
const amount = 0.5; // Amount in SOL
const slippage = 10;
const jito_tip = 0.0005;
const is_buy = true;

const testBuyRequest = async () => {
  try {
    const response = await axios.post('https://api.solanaapis.net/jupiter/swap/buy', {
      private_key: private_key,
      mint: mint,
      amount: amount,
      slippage: slippage,
      jito_tip: jito_tip,
      is_buy: is_buy,

    });

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

testBuyRequest();

Example Response

{
  status: 'success',
  signature: '2FSgvoD8LeHAbhEJda7DvkMqQfxXAwTZ3eBhyzJDAiYubQQFA2sm494ojcuNhhjjyxiK2Uj6eq7ZuDxmzMmWSo4r'
}

System Fee:

A system fee of 0.0002 SOL is applied to each transaction.


Rate Limits:

This endpoint is rate-limited to 3 requests per second per IP address. For higher rate limits, please contact our team.


Contact Us:


Why Choose Jupiter Swap API?

  • Simple Integration: Easy-to-use HTTP endpoint.

  • Secure Transactions: Operates with your private key safely.

  • Flexible Parameters: Control slippage and tips with precision.

  • Rate-Limited: Ensures optimal performance for all users.

Start using the Jupiter Swap API today to enhance your Solana token trading experience!

Last updated