# 3commas-typescript

> TypeScript 3Commas API client

Latest version **1.3.6** (published 2022-07-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install 3commas-typescript
pnpm add 3commas-typescript
yarn add 3commas-typescript
bun add 3commas-typescript
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.6 |
| Published | 2022-07-23 |
| First published | 2020-07-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 79.2 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 22 |
| Author | Kiros Choi |
| Maintainers | kirosc |
| Keywords | typescript, 3commas |

## Links

- npm: https://www.npmjs.com/package/3commas-typescript
- Repository: https://github.com/kirosc/3commas-typescript
- Issues: https://github.com/kirosc/3commas-typescript/issues
- npm.io page: https://npm.io/package/3commas-typescript

## Dependencies (4)

- [qs](https://npm.io/package/qs.md) ^6.11.0
- [ws](https://npm.io/package/ws.md) ^8.8.1
- [axios](https://npm.io/package/axios.md) ^0.27.2
- [crypto-js](https://npm.io/package/crypto-js.md) ^4.1.1

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.3.6 (latest) — 2022-07-23
- 1.3.5 — 2022-02-02
- 1.3.4 — 2021-10-23
- 1.3.3 — 2021-09-14
- 1.3.2 — 2021-08-28
- 1.3.1 — 2021-07-07
- 1.3.0 — 2021-06-29
- 1.2.3 — 2021-06-19
- 1.2.2 — 2021-05-23
- 1.2.1 — 2021-05-22
- 1.2.0 — 2021-05-15
- 1.1.3 — 2021-05-10
- 1.1.2 — 2021-02-21
- 1.1.1 — 2021-02-13
- 1.1.0 — 2021-02-13
- … 16 more at https://npm.io/package/3commas-typescript/versions

## README

# 3Commas API Client for TypeScript

![npm](https://img.shields.io/npm/v/3commas-typescript)
![npm bundle size](https://img.shields.io/bundlephobia/min/3commas-typescript)

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/kirosc/3commas-typescript)

An unofficial 3Commas API wrapper in TypeScript. Check out the offical documentation [here](https://github.com/3commas-io/3commas-official-api-docs).

## Install

```
npm install 3commas-typescript
```

## Usage

```ts
import { API } from '3commas-typescript';

const api = new API({
  key: 'YOUR_KEY', // Optional if only query endpoints with no security requirement
  secrets: 'YOUR_SECRETS', // Optional
  timeout: 60000, // Optional, in ms, default to 30000
  forcedMode: 'real' | 'paper',
  errorHandler: (response, reject) => {
    // Optional, Custom handler for 3Commas error
    const { error, error_description } = response;
    reject(new Error(error_description ?? error));
  },
});
```

## Supported Request

### Account

```ts
ping()

time()

transfer(params: TransferParams)

getTransferHistory(params: TransferHistoryParams)

getTransferData()

addExchangeAccount(params: any)

editExchangeAccount(params: any)

getExchange()

getMarketList()

getMarketPairs(params?: any)

getCurrencyRate(params: CurrencyParams)

getCurrencyRateWithLeverageData(params: MarketCurrencyParams)

getActiveTradeEntities(account_id: number)

sellAllToUSD(account_id: number)

sellAllToBTC(account_id: number)

getBalanceChartData(account_id: number, params: any)

loadBalances(account_id: number)

renameExchangeAccount(account_id: number, name: string)

removeExchangeAccount(account_id: number)

getPieChartData(account_id: number)

getAccountTableData(account_id: number)

getAccountInfo(account_id?: number)
```

### User

```ts
changeUserMode(mode: 'paper' | 'real')
```

### Smart Trade

```ts
getSmartTradeHistory(params?: SmartTradeHistoryParams)

smartTrade(params: SmartTradeParams)

getSmartTrade(id: number)

cancelSmartTrade(id: number)

updateSmartTrade(id: number)

averageSmartTrade(id: number, params: FundParams)

reduceFund(id: number, params: FundParams)

closeSmartTrade(id: number)

forceStartSmartTrade(id: number)

forceProcessSmartTrade(id: number)

setNoteSmartTrade(id: number, note: string)

getSubTrade(id: number)

closeSubTrade(smartTradeId: number, subTradeId: number)

cancelSubTrade(smartTradeId: number, subTradeId: number)

```

### Bots

```ts
getBots(params?: BotsParams)

getBot(id: number)

getBotsStats(params?: BotsStatsParams)

getDeals(params?: DealsParams)

getDeal(id: number)

getDealSafetyOrders(id: number)
```

### Custom Request

```ts
customRequest(method: string, version: number, path: string, payload?: any)
```

### Websocket

```ts
subscribeSmartTrade(callback?: (data: WebSocket.Data) => void)

subscribeDeal(callback?: (data: WebSocket.Data) => void)

unsubscribe()
```

## Response Type

The Order type returned by smart trade endpoint is generated using [quicktype](https://github.com/quicktype/quicktype).

The type correctness isn't guaranteed. You can perform a type check before access.

```ts
try {
  const order = await api.getSmartTrade(1234567)
  const validatedOrder = api.validateOrderType(order)
  ...
} catch (error) {
  console.error(error)
}
```

## Support

Buy me a coffee

ETH: 0xB6fc1dFABf1244138b048C3F80ba5678d8f6f0CE

BAT: 0x336bFB8247640C0848F8aFFB80464f3fF489B888

---
_Source: https://npm.io/package/3commas-typescript · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
