> For the complete documentation index, see [llms.txt](https://dev.simplepay.ai/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev.simplepay.ai/docs/javascript-sdk/introduction.md).

# Introduction

We provide API client libraries to simplify integration with our product

{% hint style="info" %}
Only TypeScript client is publicly available now. If you are using another language/framework, we will be glad to help you with integration, feel free to [Request API Client](mailto:info@simplepay.ai?subject=API%20Client%20Request\&body=I%27m%20interested%20in%20API%20client%20library%20for%20...) for your language or framework
{% endhint %}

## Installation

To install Client Library use package manager for your language

{% tabs %}
{% tab title="TypeScript" %}

```shell
npm install --save-dev @simplepay-ai/api-client
```

{% endtab %}
{% endtabs %}

## API Client

### Initialization

To make API requests you should create instance of API Client

{% tabs %}
{% tab title="TypeScript" %}

```typescript
import { Client } from '@simplepay-ai/api-client';

const api = new Client({
    apiKey: '<place your API key here>'
});
```

{% endtab %}
{% endtabs %}

We recommend to create a single instance of `Client` and then reuse it in different parts of your application

{% hint style="warning" %}
**Do not expose your API key when using Client in frontend application**

Exposing API key to third-parties gives them ability to bypass payment step and access paid functions of your application

API key should only be set when using Client on server-side
{% endhint %}

### Calling API methods

To get usage examples, see specific API sections:

* [🪙 Cryptocurrency](/docs/javascript-sdk/services/cryptocurrency.md#methods)
* [💵 Currency](/docs/javascript-sdk/services/currency.md#methods)
* [🧾 Invoice](/docs/javascript-sdk/services/invoice.md#methods)

## WebSocket Client

### Initialization

To subscribe to updates about invoice status changes you should create instance of WebSocket Client

{% tabs %}
{% tab title="TypeScript" %}

```typescript
import { WsClient } from '@simplepay-ai/api-client';

const ws = new WsClient();
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
WebSocket Client intended to use in frontend applications for informing end customers about status of their payments. Do not use it as handler for crediting accounts or providing them access to paid features of your application, use [Webhooks](/docs/javascript-sdk/services/invoice.md#get-invoice-from-webhook) instead
{% endhint %}

### Subscribing to events

To get usage examples, see specific API sections:

* [🧾 Invoice](/docs/javascript-sdk/services/invoice.md#websocket-channels)
