# 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)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dev.simplepay.ai/docs/javascript-sdk/introduction.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
