npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bitget-ai/bitget-agent-sdk

v1.2.0

Published

Official Bitget SDK for AI agents — 56+ Bitget API tools (spot, futures, margin, copy-trading, earn, broker, p2p, convert, account) as a typed TypeScript foundation, with a built-in mock server for testing.

Downloads

23

Readme

@bitget-ai/bitget-agent-sdk

npm Types License: MIT

The Foundation SDK of the Bitget Agent Hub — Bitget's full REST API surface as 56+ AI-callable tools, with a typed TypeScript core and a built-in mock server for testing.

npm install @bitget-ai/bitget-agent-sdk

Requirements: Node.js ≥ 20. Pure ESM — import only, no require().

Why this package

If you are writing code against the Bitget API — quant strategies, trading bots, custom MCP servers, internal platform tooling — this is the package you want. It exposes a registry of 56+ Bitget tools (spot, futures, margin, copy-trading, earn, broker, p2p, convert, account) with consistent schemas, ready to plug into any AI agent or LLM tool-use framework.

If you instead want to operate a Bitget account from your shell or AI assistant, you don't need this directly — pick one of the surfaces built on top:

Quick start

import { loadConfig, buildTools, BitgetRestClient } from "@bitget-ai/bitget-agent-sdk";

const config = loadConfig({ modules: "all", readOnly: false });
const tools = buildTools(config);
const client = new BitgetRestClient(config);

// Each tool: { name, description, module, isWrite, inputSchema, handler }
console.log(`Loaded ${tools.length} tools`);

// Invoke a tool
const ticker = tools.find((t) => t.name === "spot_get_ticker")!;
const result = await ticker.handler(
  { symbol: "BTCUSDT" },
  { config, client },
);

Public API

// Client + tooling primitives
import { BitgetRestClient, buildTools, loadConfig } from "@bitget-ai/bitget-agent-sdk";

// Types
import type {
  BitgetConfig,
  CliOptions,
  ToolSpec,
  ToolContext,
  ModuleId,
} from "@bitget-ai/bitget-agent-sdk";

// Metadata
import {
  SERVER_NAME,
  SERVER_VERSION,
  MODULES,
  DEFAULT_MODULES,
} from "@bitget-ai/bitget-agent-sdk";

// Errors
import {
  BitgetMcpError,
  BitgetApiError,
  ConfigError,
  ValidationError,
  RateLimitError,
  AuthenticationError,
  NetworkError,
  toToolErrorPayload,
} from "@bitget-ai/bitget-agent-sdk";

The SDK follows semver. Anything not exported from the package root or the @bitget-ai/bitget-agent-sdk/testing subpath is internal and may change without notice.

Modules and tools

| Module | Tools | Loaded by default | |--------|:-----:|:-----------------:| | spot | 13 | ✅ | | futures | 14 | ✅ | | account | 8 | ✅ | | margin | 7 | — | | copytrading | 5 | — | | convert | 3 | — | | earn | 3 | — | | p2p | 2 | — | | broker | 3 | — |

Default: 35 tools (fits Cursor's 40-tool MCP limit). Load everything: loadConfig({ modules: "all" }).

Testing with the built-in mock server

The @bitget-ai/bitget-agent-sdk/testing subpath ships an in-memory Bitget API simulator so you can integration-test against real client code without touching live endpoints.

import { MockServer } from "@bitget-ai/bitget-agent-sdk/testing";
import { loadConfig, BitgetRestClient } from "@bitget-ai/bitget-agent-sdk";

const mock = new MockServer();
await mock.start();

const config = loadConfig({
  modules: "spot",
  readOnly: false,
  baseUrl: mock.url,
  apiKey: "test",
  apiSecret: "test",
  passphrase: "test",
});
const client = new BitgetRestClient(config);

// ... drive your tests against `client` ...

await mock.stop();

You can also run the mock as a standalone HTTP process — useful for shell-based integration tests or hand-driving requests with curl:

npx bitget-mock-server --port 9876
# Mock listening on http://127.0.0.1:9876

The bitget-mock-server binary ships with this package; no separate install needed.

Error handling

All Bitget API failures and config problems are surfaced as typed Error subclasses you can instanceof-narrow:

import {
  BitgetApiError,
  ConfigError,
  ValidationError,
  RateLimitError,
} from "@bitget-ai/bitget-agent-sdk";

try {
  await tool.handler(args, ctx);
} catch (err) {
  if (err instanceof RateLimitError) {
    // Back off and retry — SDK already applies client-side rate limiting
    // by default, but Bitget can still 429 under load.
  } else if (err instanceof BitgetApiError) {
    console.error(err.code, err.message);
  } else if (err instanceof ConfigError) {
    // Missing/invalid credentials — surface to the user
  }
}

For surfacing errors to LLM tool-use frameworks, use toToolErrorPayload(err) to get a JSON-serialisable error payload with { ok: false, error: { type, message, ... } }.

Compatibility

  • Node.js: ≥ 20.0.0
  • Module format: ESM only ("type": "module"). Tree-shaking enabled ("sideEffects": false).
  • TypeScript: types ship in the package; no @types/... install needed.
  • Bundlers: verified with tsup, esbuild, rollup, vite. The ./testing subpath is excluded from the main entry chunk so production bundles do not pull in the mock server.

Documentation

Full reference — modules, tool catalog, error codes, architecture — lives in the portal: bitget/agent-hub.

License

MIT


Part of the Bitget Agent Hub — Trading Stack · Foundation.

Surfaces: agent-cli · agent-mcp · agent-skill