---
title: "Binance REST Spot Private Autoinvest Example | Siebly"
description: "Binance REST spot private autoinvest JavaScript example for the Siebly Binance SDK, covering exchange REST API and WebSocket integration, setup, and production SDK docs."
canonical: "https://siebly.io/examples/Binance/Rest/Spot/rest-spot-private-autoinvest"
robots: "index,follow"
---

# Binance REST Spot Private Autoinvest Example

Binance REST spot private autoinvest JavaScript example for the Siebly Binance SDK, covering exchange REST API and WebSocket integration, setup, and production SDK docs.

**Path:** [Home](/) / [Examples](/examples) / [Binance](/examples/Binance) / [Rest](/examples/Binance/Rest) / [Spot](/examples/Binance/Rest/Spot) / [rest-spot-private-autoinvest.ts](/examples/Binance/Rest/Spot/rest-spot-private-autoinvest)

[View source on GitHub](https://github.com/sieblyio/crypto-api-examples/blob/master/examples/Binance/Rest/Spot/rest-spot-private-autoinvest.ts)

[Open the Binance JavaScript SDK guide](/sdk/binance/javascript)

## rest-spot-private-autoinvest.ts

```typescript
import { MainClient } from 'binance';

const key = process.env.API_KEY_COM || 'APIKEY';
const secret = process.env.API_SECRET_COM || 'APISECRET';

const client = new MainClient({
  api_key: key,
  api_secret: secret,
  beautifyResponses: true,
});

(async () => {
  try {
    const oneTimeTransactionResult =
      await client.submitAutoInvestOneTimeTransaction({
        sourceType: 'MAIN_SITE',
        subscriptionAmount: 100,
        sourceAsset: 'USDT',
        details: [
          {
            targetAsset: 'BTC',
            percentage: 60,
          },
          {
            targetAsset: 'ETH',
            percentage: 40,
          },
        ],
      });

    console.log('oneTimeTransactionResult', oneTimeTransactionResult);

    const autoInvestPlanResult = await client.submitAutoInvestmentPlan({
      UID: '54545454',
      sourceType: 'MAIN_SITE',
      subscriptionAmount: 100,
      sourceAsset: 'USDT',
      planType: 'SINGLE',
      flexibleAllowedToUse: true,
      subscriptionCycle: 'DAILY',
      subscriptionStartTime: 5,
      details: [
        {
          targetAsset: 'BTC',
          percentage: 100,
        },
      ],
    });

    console.log('autoInvestPlanResult', autoInvestPlanResult);
  } catch (e) {
    console.error('request failed: ', e);
  }
})();
```
