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

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

<iframe className="w-full aspect-video rounded-xl" src="https://www.youtube.com/embed/gz6GU5kAUXY?si=54lqva3t6lzKjvdH&start=145" title="Video" frameBorder="0" allowFullScreen />

***

## Generate your API Key

1. Open the [**DeFindex Console**](https://console.defindex.io/) and create your account, or log in.
2. Go to **API Keys** and click **Generate API Key**.
3. Copy the key. It looks like `sk_...` and it is the only credential your backend needs.

You hold one active API key at a time: generating a new one revokes the previous one.

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

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

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.

## 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](/integration-guide/guides-and-tutorials/getting-api-key)

***

## 1. Setting Up the API Client

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

```typescript theme={null}
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();
    }

    // Submit a signed transaction. POST /send lives at the API root, not under a vault.
    async send(signedXdr: string): Promise<any> {
        const response = await fetch(`https://${this.apiUrl}/send`, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'Authorization': `Bearer ${this.apiKey}`
            },
            body: JSON.stringify({ xdr: signedXdr })
        });
        return await response.json();
    }
}
```

Go to [Vault Operations](/integration-guide/vault-operations/index) for the implementation of each call:

* Deposit
* Withdraw
* Balance
* APY

***

## Request Parameters Reference

### Deposit Request

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

### Withdraw Request

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

### Send Request

Sent to `POST /send`, at the API root rather than under a vault path.

```javascript theme={null}
{
    xdr: signedXdr          // Signed transaction XDR
}
```
