Skip to content

Latest commit

 

History

History
286 lines (232 loc) · 5.87 KB

README.md

File metadata and controls

286 lines (232 loc) · 5.87 KB
description icon
This API allows users to trade SunPump tokens using TRX. This includes Buy and Sell transactions.
webhook

🚧 Webhooks

Endpoint

  • URL: /sunpump/trade
  • Method: POST
  • Content-Type: application/json
  • API Key Header: api-key: your-api-key-here

Request Body

Parameter Type Required Description
action string Yes

Type of transaction:

buy or sell

tokenAddress string Yes Token Contract Address
amount number Yes Amount to trade (TRX for Buys)
slippage number No Max allowed price change before transaction is reverted
priorityFee number No Tip to speed up transactions (experimental ⚠️)

Example Request

{% tabs %} {% tab title="cURL" %}

curl -X POST "https://api.dangeracorn.bot/sunpump/trade" \
-H "Content-Type: application/json" \
-H "api-key: your-api-key" \
-d '{
  "action": "buy",
  "tokenAddress": "TXu7ZTRhX5FqGbVNGg81DovGHedZXPQB1A",
  "amount": 100,
  "slippage": 5,
  "priorityFee": 10,
  "privateKey": "your-private-key"
}'

{% endtab %}

{% tab title="JavaScript" %} {% code title="npm install axios" %}

const axios = require('axios');

const data = {
  action: "buy",
  tokenAddress: "TXu7ZTRhX5FqGbVNGg81DovGHedZXPQB1A",
  amount: 100,
  slippage: 5,
  priorityFee: 10,
  privateKey: "your-private-key"
};

axios.post('https://api.dangeracorn.bot/sunpump/trade', data, {
  headers: {
    'Content-Type': 'application/json',
    'api-key': 'your-api-key'
  }
})
.then(response => {
  console.log(response.data);
})
.catch(error => {
  console.error(error);
});

{% endcode %} {% endtab %}

{% tab title="Python" %} {% code title="pip install requests" %}

import requests

url = 'https://api.dangeracorn.bot/sunpump/trade'
headers = {
    'Content-Type': 'application/json',
    'api-key': 'your-api-key'
}
data = {
    "action": "buy",
    "tokenAddress": "TXu7ZTRhX5FqGbVNGg81DovGHedZXPQB1A",
    "amount": 100,
    "slippage": 5,
    "priorityFee": 10,
    "privateKey": "your-private-key"
}

response = requests.post(url, json=data, headers=headers)
print(response.json())

{% endcode %} {% endtab %}

{% tab title="Node.js" %}

const https = require('https');

const data = JSON.stringify({
  action: 'buy',
  tokenAddress: 'TXu7ZTRhX5FqGbVNGg81DovGHedZXPQB1A',
  amount: 100,
  slippage: 5,
  priorityFee: 10,
  privateKey: 'your-private-key'
});

const options = {
  hostname: 'api.dangeracorn.bot',
  port: 443,
  path: '/sunpump/trade',
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'api-key': 'your-api-key'
  }
};

const req = https.request(options, (res) => {
  let responseData = '';

  res.on('data', (chunk) => {
    responseData += chunk;
  });

  res.on('end', () => {
    console.log(JSON.parse(responseData));
  });
});

req.on('error', (e) => {
  console.error(e);
});

req.write(data);
req.end();

{% endtab %}

{% tab title="Go" %}

package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
)

func main() {
    url := "https://api.dangeracorn.bot/sunpump/trade"
    apiKey := "your-api-key"

    data := map[string]interface{}{
        "action":       "buy",
        "tokenAddress": "TXu7ZTRhX5FqGbVNGg81DovGHedZXPQB1A",
        "amount":       100,
        "slippage":     5,
        "priorityFee":  10,
        "privateKey":   "your-private-key",
    }

    jsonData, _ := json.Marshal(data)

    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("api-key", apiKey)

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    defer resp.Body.Close()

    fmt.Println("Response Status:", resp.Status)
    // Additional response parsing can go here
}

{% endtab %}

{% tab title="PHP" %}

<?php
$api_url = "https://api.dangeracorn.bot/sunpump/trade";
$api_key = "your-api-key";

$data = array(
    "action" => "buy",
    "tokenAddress" => "TXu7ZTRhX5FqGbVNGg81DovGHedZXPQB1A",
    "amount" => 100,
    "slippage" => 5,
    "priorityFee" => 0.002,
    "privateKey" => "your-private-key"
);

$ch = curl_init($api_url);

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'api-key: ' . $api_key
));

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

if(curl_errno($ch)) {
    echo 'Request Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
?>

{% endtab %} {% endtabs %}

Example Response JSON

{
  "signature": "b69f27c7bfcf54a464294f1df99aaeff1b53714a12a80460709b20923a24486c",
  "status": "success",
  "code": "200"
}

Example Error Responses

Invalid Parameters:

jsonCopy code{
  "error": "Invalid parameters",
  "message": "You must provide action, tokenAddress, amount, and privateKey",
  "code": "400"
}

Max Slippage Reached:

jsonCopy code{
  "error": "Simulation failed",
  "message": "Max slippage reached",
  "code": "500"
}

Insufficient Funds:

jsonCopy code{
  "error": "Insufficient funds",
  "message": "Your account does not have enough funds to perform this transaction.",
  "code": "400"
}

Invalid Action:

jsonCopy code{
  "error": "Invalid action",
  "message": "Action must be either 'buy' or 'sell'",
  "code": "400"
}