Autosnipe
  • GETTING STARTED
    • 🔥 Welcome
    • ⚙️ Wallet Setup
      • Login & Wallet Connect
      • Autosnipe Wallet
      • Deposit
      • Withdrawal
      • FAQs
    • 🔗 Useful Links
  • Platform
    • 🔥Burn & Sell Rugged Tokens
    • 🧭 Platform Navigation
    • ✨ Trader Lens - Wallet Analyzer
    • 💡 Notification Alerts
    • ⚡️ Scam & Rug Detection
    • 💊 Filters
  • Buy & Sell
    • ⚙️ Slippage & Gas Settings
    • 🟥 Buys - Market & Limit Orders
    • 🟩 Sells - Market & Limit Orders
    • 🟨 Holdings & Trade History
    • 💰 Fees
  • Advanced Trading
    • Advanced Trading Features
    • 🤖 AI Sniper - Trade Automation
      • Intro
      • Set-up & Activation
      • Profit & Loss / Trading History
      • FAQ & Troubleshooting:
    • ⚡️ Copy Trading
      • Set Up & Activate Copy Trading
      • Trading History
      • Profit & Loss
      • Frequently Asked Questions
    • 💻Autosnipe API Trading
      • Autosnipe Node SDK
      • Autosnipe Rest APIS
        • 📖Authentication
          • 🔶Get Pairs
          • 🟢Buy Token
          • 🔴Sell Token
          • 🟩Limit Order Buy Token
          • 🟥Limit Order Sell Token
          • 🟨List Limit Order
          • ❌Cancel Limit Order
          • ⚖️Users Holdings
  • Referral & Partner Growth
    • 💸 Referral Program
    • 🤝 KOL & Partner Growth
  • Miscellaneous
    • Others
      • 💰 Fees
      • ❓ FAQ
      • 🔔 Terms of Use
      • ⚠️ Privacy Policy
      • ✅ Transparency Disclosure
Powered by GitBook
On this page
  1. Advanced Trading
  2. Autosnipe API Trading
  3. Autosnipe Rest APIS

Authentication

For making a Authenticated API call, get the API Credentials from Dashboard and use them in the following example snippet.

PreviousAutosnipe Rest APISNextGet Pairs

Last updated 10 months ago

All Authenticated APIs require a body object with url and timeStamp_nonce as mandatory keys along with the required params of the API being called. Create a signature using the payload and api secret and pass it along with the payload in headers.

Base URL

Creating Signature and Making Auth API Calls

let data = {
   "key": <YOUR_API_KEY>,
   "Secret": <YOUR_API_SECRET>,
}
const crypto = require('crypto');
const request = require('request');
const base_url = "https://api.autosnipe.ai/sniper-api";

async function callAuthAPI(end_point, body = {}, method) {
   const timeStamp_nonce = Date.now().toString();
   body.url = base_url + end_point;
   body.timeStamp_nonce = timeStamp_nonce;
   
   let payload = getPayload(body);
   let signature = getSignature(payload, data.Secret);

   let headers = {
       'x-autosnipe-apikey': data.key,
       'x-autosnipe-signature': signature,
       'Content-Type': 'application/json'
   };
  

   let options = {
       url: body.url,
       method: method,
       headers: headers,
       body: JSON.stringify(body)
   }

   request(options, function(error, res, body) {
       if (!error) {
           try {
               console.log({ error, res, body });
           } catch (err) {
               console.log("Error ", err);
           }
       } else {
           console.log("Error2 ", error);
       }
   });
}

function getPayload(body) {
   const content = {
     url: body.url,
     timeStamp_nonce: body.timeStamp_nonce,
     body: JSON.stringify(body)
   };
   return Buffer.from(JSON.stringify(content)).toString('base64');
}

function getSignature(payload, apiSecretKey) {
   return crypto.createHmac('sha512', apiSecretKey)
                .update(payload)
                .digest('hex');
}
💻
📖
https://api.autosnipe.ai/sniper-api/