> ## Documentation Index
> Fetch the complete documentation index at: https://cobo.com/payments/llms.txt
> Use this file to discover all available pages before exploring further.

# Get started with JavaScript SDK

This guide introduces how to get started with using the Cobo Payments JavaScript SDK, which allows you to integrate the Cobo payments service into your existing application using the JavaScript programming language.

To learn more about the initial setup steps necessary for utilizing the Payments API, see [Send your first request](/payments/en/developer-tools/get-started-with-api).

You can go to [GitHub](https://github.com/CoboGlobal/cobo-waas2-js-sdk/) to access the source code of the SDK.

## Prerequisites

* Install Node.js and NPM.
* Follow the instructions in [Preparation for development environment](/payments/en/guides/preparation) to set up your Cobo account and create your organization. If an organization has already been set up, ask your organization admin to invite you to join the organization.
* Follow the instructions in [Send your first request](/payments/en/developer-tools/get-started-with-api) to generate an API key and an API secret, and register the API key on Cobo Portal.

## Create a project and install the SDK

1. Create a project directory and initialize NPM:

```bash theme={null}
mkdir waas2-js && cd waas2-js
npm init -y
```

2. Install the SDK:

```bash theme={null}
npm install @cobo/cobo-waas2 --save
```

The directory structure after installation is as follows:

```text theme={null}
waas2-js/
├─ node_modules/
├─ package.json
├─ package-lock.json
└─ (to be created later) index.js
```

<Tip> If your project already has <code>package.json</code> and <code>package-lock.json</code>, you can directly copy them to the root directory and run <code>npm install</code> to pull dependencies.</Tip>

3. Create a file <code>index.js</code> in the root directory and paste the following code into it.

The directory structure after installation is as follows:

```text theme={null}
waas2-js/
├─ node_modules/
├─ package.json
├─ package-lock.json
└─ (to be created later) index.js
```

<Tip> If your project already has <code>package.json</code> and <code>package-lock.json</code>, you can directly copy them to the root directory and run <code>npm install</code> to pull dependencies.</Tip>

## Configure API key and HTTP host

1. Set the API secret.

```javascript theme={null}
// Initialize the default API client
const apiClient = CoboWaas2.ApiClient.instance
// Set the API secret
apiClient.setPrivateKey("<YOUR_API_SECRET_IN_HEX>");
```

2. Select which [environment](/payments/en/developer-tools/environments) you want to use.

```javascript theme={null}
// Select the development environment
apiClient.setEnv(CoboWaas2.Env.DEV);

// Select the production environment
apiClient.setEnv(CoboWaas2.Env.PROD);
```

## Code sample

For operation-specific documentation and sample code, see the [docs](https://github.com/CoboGlobal/cobo-waas2-js-sdk/tree/master/docs) folder in the Payments GitHub repository.
