> For the complete documentation index, see [llms.txt](https://the-swapper-project.gitbook.io/the-swapper/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://the-swapper-project.gitbook.io/the-swapper/swap-api/quick-start.md).

# Quick Start

## **GET API Key**

{% hint style="info" %}
You can't get your personal API key yet. As of February 28, 2023, this function will work.
{% endhint %}

Swapper API works with API Key. This API key is unique and private. You should use this API key for requests you send from your server or frontend. Undesirable results may occur if this API key is started to be used by 3rd parties. So do not share your API Key with anyone. Swapper is currently developing a Dashboard to generate API Key. Until then you can use this API Key:

```
API Key: Ru31BKdr99rGlsyN69
```

## 1. Install Swapper

The easiest way to integrate the Swapper SDK into your JavaScript project is through the npm module.

Install the package via `npm`:

```javascript
npm install swapper
```

Adding Swapper to the frontend project is by the following

```javascript
import Swapper from 'swapper';
```

## 2. Initialize Swapper

After your dependency is added, you simply need to initialize swapper with class initialization:

{% hint style="info" %}
**Warning**: Make sure to keep your api key private
{% endhint %}

```javascript
const service = new Swapper({ apiKey: 'YOUR_API_KEY' });
```

## 3. Using Dex API endpoints

After that we can use service functions to interact with the Dex API and Web3 wallet.

```javascript
// ...

const priceResponse = await service.getPrice({
  buyTokenAddress: '0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56',
  sellTokenAddress: '0x3019bf2a2ef8040c242c9a4c5c4bd4c81678b2a1',
  sellTokenAmount: '1000000000000000000',
});

const quoteResponse = await service.getQuote({
  buyTokenAddress: '0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56',
  sellTokenAddress: '0x3019bf2a2ef8040c242c9a4c5c4bd4c81678b2a1',
  sellTokenAmount: '1000000000000000000',
});
```

### 4. Using services and utils

There are some utility functions which can help you build your dex even more quicker,

```javascript
// ...

// This will initialize and configure the current Web3 wallet.
service.utils.connectWallet({ chainId: 56 });

// This will create an allowance based on your params on your web3 wallet for the desired token.
service.setAllowance({
  ownerAddress: '0x123', // your web3 wallet address
  sellTokenAddress: '0x3019bf2a2ef8040c242c9a4c5c4bd4c81678b2a1', // token address to create allowance for
});
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://the-swapper-project.gitbook.io/the-swapper/swap-api/quick-start.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.
