> For the complete documentation index, see [llms.txt](https://docs.defindex.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.defindex.io/api-integration-guide/api.md).

# Introduction

## 🎬 Video Tutorial

Prefer learning by watching? Check out our integration walkthrough:

[Watch the integration walkthrough on YouTube](https://www.youtube.com/watch?v=gz6GU5kAUXY\&t=145s):

{% embed url="<https://www.youtube.com/embed/gz6GU5kAUXY?si=54lqva3t6lzKjvdH&start=145>" %}

***

## Generate your API Key

Follow these steps to get your API key:

1. **Register** → <https://api.defindex.io/register>
2. **Login** → <https://api.defindex.io/login>
3. **Create API Key** — from your dashboard, generate your `api_key` and `refresh_token`.

For a detailed walkthrough with examples, see the [**Getting Your API Key guide**](/api-integration-guide/guides-and-tutorials/getting-api-key.md).

For the full API reference, see the [DeFindex API documentation](https://api.defindex.io/docs).

Postman collection json [here](https://github.com/defindex-io/docs/blob/main/api-integration-guide/postman_collection.json)

This guide will walk you through integrating DeFindex into your app using the provided API. We'll use TypeScript for the examples, but the concepts apply to any language.

## 🚀 TypeScript SDK Available!

If you're developing in TypeScript, we highly recommend using our official SDK instead of direct API integration. The SDK provides:

* Type safety and comprehensive TypeScript definitions
* Simplified authentication with API keys
* Built-in error handling and validation
* Complete coverage of all API endpoints
* Working examples and detailed documentation

[**Check out the DeFindex TypeScript SDK documentation**](/advanced-documentation/sdks/02-defindex-sdk.md) **for the easiest integration experience.**

For non-TypeScript projects or custom integrations, continue with this direct API guide below.

***

Complete reference: [API Reference](https://api.defindex.io/docs)

## Prerequisites

* Basic knowledge of TypeScript or JavaScript
* Node.js environment
* [Stellar SDK](https://www.stellar.org/developers/reference/) installed (`npm install stellar-sdk`)
* DeFindex API key — see [Getting Your API Key](/api-integration-guide/guides-and-tutorials/getting-api-key.md)

***

## 1. Setting Up the API Client

First, create an `ApiClient` class to handle authentication and API requests.

```typescript
import StellarSdk from 'stellar-sdk';

class ApiClient {
    private readonly apiUrl = "api.defindex.io";
    private readonly apiKey: string;

    constructor(apiKey: string) {
        this.apiKey = apiKey;
    }

    // Helper for POST requests
    async postData(endpoint: string, vaultAddress: string, params: Record<string, any>): Promise<any> {
        const response = await fetch(`https://${this.apiUrl}/vault/${vaultAddress}/${endpoint}`, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'Authorization': `Bearer ${this.apiKey}`
            },
            body: JSON.stringify(params)
        });
        return await response.json();
    }

    // Helper for GET requests
    async getData(endpoint: string, vaultAddress: string, params?: Record<string, any>): Promise<any> {
        const url = params
            ? `https://${this.apiUrl}/vault/${vaultAddress}/${endpoint}?${new URLSearchParams(params).toString()}`
            : `https://${this.apiUrl}/vault/${vaultAddress}/${endpoint}`;

        const response = await fetch(url, {
            method: 'GET',
            headers: {
                'Authorization': `Bearer ${this.apiKey}`
            }
        });
        return await response.json();
    }
}
```

Go to[ interact with vault](/api-integration-guide/smart-contracts.md), see the implementations of the functions:

* Deposit
* Withdraw
* Balance
* APY

***

## Request Parameters Reference

### Deposit Request

```javascript
{
    amounts: [10000000],     // Array of amounts for each vault asset (7 decimals for XLM)
    caller: userAddress,     // User's wallet address
}
```

### Withdraw Request

```javascript
{
    amounts: [5000000],      // Array of amounts to withdraw from each asset
    caller: userAddress,     // User's wallet address
}
```

### Send Request

```javascript
{
    xdr: signedXdr          // Signed transaction XDR
}
```
