Skip to main content

Gunbot JavaScript SDK – Your Shortcut to Automated Trading

· 6 min read

Symbol image of gunbot js sdk

Ship your trading ideas faster: the open-source Gunbot JavaScript SDK wraps the Gunbot REST API in a single NPM package, with strong TypeScript types and one-line calls for spot, futures and DeFi markets. Whether you're a battle-hardened dev or just exploring automated trading, the SDK turns "send orders" and "pull balances" into a few readable lines of code—no boilerplate, no guesswork.

TL;DR

  • Direct REST calls are history: gunbot-sdk-js gives you strongly-typed methods and a unified payload structure
  • Works everywhere: Node 18+, browsers, serverless, Deno, Bun
  • 100% open-source (MIT): fork it, extend it, ship it
  • Brand-new to Gunbot? Start with the GUI today, graduate to the SDK tomorrow without changing tools

Grab it now:

Why Developers Asked for an SDK

Building trading applications directly against REST APIs is tedious and error-prone. You're constantly assembling URLs, crafting JSON payloads by hand, and hoping your homemade TypeScript interfaces match the server schema. One small typo in a parameter name, and your order fails silently. Miss a required field, and you're debugging authentication errors at 2 AM.

The Gunbot JavaScript SDK eliminates this friction by providing a developer-first abstraction layer that feels natural to use:

Without SDKWith gunbot-sdk-js
Manual URLs & payloadsCall intuitive methods like configPairAdd()
Hand-written interfacesTypes auto-generated from OpenAPI
Different shapes per marketOne consistent payload format
Build tweaks for ESM/CJSWorks out-of-the-box everywhere

The Problem with Raw API Calls

Let's be honest: working with trading APIs directly is a pain. You end up with code that looks like this:

// The old way - error-prone and verbose
const response = await fetch(`${baseUrl}/api/v1/config/addpair`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
exchange: 'binance',
pair: 'BTC-USDT',
// Wait, was it 'base' or 'baseCurrency'?
// Let me check the docs again...
})
});

With the SDK, that same operation becomes:

// The SDK way - clean and type-safe
await gunbot.configPairAdd({
exchange: 'binance',
pair: 'BTC-USDT',
settings: {}
});

Your IDE provides autocomplete, TypeScript catches errors before runtime, and you spend more time building features instead of debugging API calls.

Install in Under a Minute

Getting started is straightforward:

npm install gunbot-sdk-js
# or yarn add gunbot-sdk-js
# or pnpm add gunbot-sdk-js

The package exposes ESM, CommonJS and bundled .d.ts types via exports, so your toolchain picks the right build automatically. No configuration required, no build step headaches.

Three-Line Setup

import { ApiClient, GunbotApi } from 'gunbot-sdk-js';

const api = ApiClient.instance;
api.basePath = 'http://<your-gunbot-host>:3000/api/v1';
api.authentications.BearerAuth = {
type: 'oauth2',
accessToken: '<your-api-token>'
};

const gunbot = new GunbotApi(api);

That's it. You're ready to start making API calls.

Real-World Examples

Portfolio Overview

Want to see your total USDT assets on Binance for the last 24 hours?

const assets = await gunbot.assetsTotal({
exchange: 'binance',
base: 'USDT',
start: Date.now() - 86400000,
end: Date.now()
});

console.log(`Total USDT value: ${assets.data.total}`);

Strategy Management

Add a new trading pair to your strategy configuration:

await gunbot.configPairAdd({
exchange: 'binance',
pair: 'ETH-USDT',
settings: {}
});

Universal Compatibility

The SDK works in every modern JavaScript environment:

EnvironmentStatusNotes
Node 18+Full feature support
Deno & BunNative ESM support
Modern browsers (Vite/Next)Works with all major bundlers
AWS Lambda / Cloud FunctionsPerfect for serverless trading bots
TypeScript strict modeType-safe throughout

Browser Usage

When using the SDK in browsers, it integrates seamlessly with popular frameworks like React, Vue, and Angular, making it easy to build trading interfaces and dashboards.

Serverless Functions

The SDK is ideal for serverless trading applications. Its small footprint and zero dependencies (beyond the generated client) mean fast cold starts and minimal bundle sizes.

Open Source & Community

Licensed under MIT, the SDK lives on GitHub and welcomes contributions.

Contributing is easy:

  1. Fork the repository
  2. Create your feature branch
  3. Add tests for new functionality
  4. Submit a pull request

Security Best Practices

When using the SDK in production:

  • Never hardcode API tokens: Use environment variables or secure vaults
  • Implement proper authentication: Follow OAuth2 best practices for token management
  • Use HTTPS: Always connect to Gunbot over secure connections, unless used on localhost

New to Gunbot?

Gunbot powers automated trading strategies on 20+ exchanges, from Binance and Coinbase to decentralized exchanges like Uniswap. The platform offers:

  • Pre-built strategies: DCA, grid trading, arbitrage, and more
  • Strategy builder: No coding required for basic automation
  • Backtesting tools: Test strategies against historical data
  • Risk management: Stop losses, trailing stops, and position sizing
  • Multi-exchange support: Trade across dozens of venues simultaneously

The SDK isn't mandatory at all for using Gunbot, but it unlocks deeper automation possibilities — custom dashboards, AI signal integrations, CI/CD pipeline checks, and complex multi-strategy orchestration — whenever you're ready to level up your trading operation.

Ready to Build?

Getting started takes just four steps:

  1. Install the SDK: npm install gunbot-sdk-js
  2. Configure the client: Point api.basePath at your Gunbot REST host
  3. Authenticate: Drop in a bearer token from the GUI or use authLogin()
  4. Start building: Automate trades, tweak strategies, and pull balances with just a few lines of code

The SDK documentation includes comprehensive examples, from simple balance checks to complex multi-exchange arbitrage bots. Whether you're building a weekend project or a production trading system, the Gunbot JavaScript SDK gives you the tools to ship faster and with confidence.

Ready to turn your trading ideas into code? Install the SDK today and join the community of developers automating their way to better trading results.