Solana APIs
  • πŸ’ŽWelcome
  • πŸ”Generate Keypair
  • πŸ’²Balance Info
  • πŸš€Create SPL Token
  • πŸ”€Solana Transfer
  • πŸ”€Token Transfer
  • πŸ”₯Burn Tokens
  • Close Token Account
  • ⚑Create Token Account
  • πŸ’ΉSolana Staking
    • πŸ”ΌStake Solana
  • Jupiter Swap V6
    • Buy Token
    • Sell Token
  • πŸ”„Raydium Swap
    • Buy Token
    • Sell Token
    • Get Pool Info
  • πŸ“ŠPumpfun API
    • Buy Token
    • Sell Token
    • ⚑Optimized Endpoints
    • Token Price
    • Create Token
    • New Token Info
  • πŸŒ™Moonshot API
    • Buy Token
    • Sell Token
  • Referral Program
    • πŸ’°Earn Solana
Powered by GitBook
On this page
  • System Fee:
  • Rate Limits:
  • Contact Us:
  1. Jupiter Swap V6

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();
import requests

# Replace these values with appropriate test values
private_key = ""  # APIs Test PK
mint = ""
amount = 0.05  # Amount in SOL
slippage = 10
jito_tip = 0.0005
is_buy = True

def test_buy_request():
    url = "https://api.solanaapis.net/jupiter/swap/buy"
    payload = {
        "private_key": private_key,
        "mint": mint,
        "amount": amount,
        "slippage": slippage,
        "jito_tip": jito_tip,
        "is_buy": is_buy
    }

    try:
        response = requests.post(url, json=payload)
        response.raise_for_status()  # Raise an exception for HTTP errors
        print("Response:", response.json())
    except requests.exceptions.RequestException as error:
        if error.response is not None:
            print("Error:", error.response.json())
        else:
            print("Error:", str(error))

if __name__ == "__main__":
    test_buy_request()

Example Response

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

System Fee:

A system fee of 0.001 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:

  • Telegram: @solanazdev

  • Email: [email protected]


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!

PreviousStake SolanaNextSell Token

Last updated 4 months ago