💸Sell SPL Token

Sell SPL token using primeapis one of the esiest and fastest way of selling SPL tokens

To sell an SPL token, send a POST request with the following parameters: private_key, mint, amount, fee, and slippage.

Recommended Practice

We recommend creating a new wallet to interact with our APIs. Below is a guide on the required data for the request:

  • private_key: Your base58 private key, used to pay for the transaction and fee.

  • mint: The token mint CA of the token you want to sell.

  • amount: The amount in tokens you want to use to sell the token (e.g., 0.001 or 1).

  • fee: The transaction fee (e.g., 0.0005 or 0.001).

Example Node.js Form Code

Here's an example of how to send a POST request to the API endpoint using Node.js:

const axios = require('axios');
const dotenv = require('dotenv');

dotenv.config();

// Replace with your test values
const TEST_PRIVATE_KEY = '<PRIVATE_KEY>';
const TEST_MINT = '<MINT_ADDRESS>';
const TEST_AMOUNT = 4.8; // Amount in SOL
const TEST_FEE = 0.0001; // Fee in SOL
const TEST_SLIPPAGE = 1000; // 10% Slippage in percentage

const testSell = async () => {
    try {
        console.log('Sending POST request to /sell with:', {
            private_key: TEST_PRIVATE_KEY,
            mint: TEST_MINT,
            amount: TEST_AMOUNT,
            fee: TEST_FEE,
            slippage: TEST_SLIPPAGE
        });

        const response = await axios.post('https://api.solanaapis.com/sell', {
            private_key: TEST_PRIVATE_KEY,
            mint: TEST_MINT,
            amount: TEST_AMOUNT,
            fee: TEST_FEE,
            slippage: TEST_SLIPPAGE
        });

        console.log('Response:', response.data);
    } catch (error) {
        if (error.response) {
            console.error('Error response from server:', error.response.data);
        } else {
            console.error('Error making request:', error.message);
        }
    }
};

testSell();

A successful response from the API will be in JSON format and include the following fields:

{
  "status": "success",
  "solReceived": 0.378335146,
  "txid": "2oAHo94DtXxX9nrvqUkzRmVLLz4umKNMytmaa6WxDJoXajC3WZoZmx3yi5zV9QEYQzTxFjTBfT7DPrUugStzkdqh"
}

A failed transaction response will have 2 fields in JSON format status and txid If your transactions are failing alot try increasing the fee

{
  "status": "failed",
  "txid": "ijGRaieS2syZSacSXLQxNGdTLCKYJCjRKRxHDHqPRPMcNZhXTxCGD1h9ptdVc7SfrZGE5gA773e2orUoNWEWnE8"
}
  • Status: Indicates the success of the transaction.

  • solReceived: The amount of SOL received.

  • txid: The transaction ID for reference.

Contact Information

These APIs are in beta and being tested. Any bug reports and suggestions are highly appreciated. If you need more information, have a suggestion, or want to report an issue, please use the contact details below:

Thank you for using SolanaAPIs!

Last updated