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

# Installation

> How to install and set up the Vepler SDK

## Requirements

Before installing the Vepler SDK, ensure you have:

* Node.js 18.0 or higher
* npm, yarn, pnpm, or bun package manager
* A Vepler API key ([get one here](https://app.vepler.com))

## Installation

Choose your preferred package manager:

<Tabs>
  <Tab title="npm">
    ```bash theme={null}
    npm install @vepler/sdk
    ```
  </Tab>

  <Tab title="yarn">
    ```bash theme={null}
    yarn add @vepler/sdk
    ```
  </Tab>

  <Tab title="pnpm">
    ```bash theme={null}
    pnpm add @vepler/sdk
    ```
  </Tab>

  <Tab title="bun">
    ```bash theme={null}
    bun add @vepler/sdk
    ```
  </Tab>
</Tabs>

## Verify Installation

Check that the SDK is installed correctly:

```bash theme={null}
npm list @vepler/sdk
```

## Basic Setup

### 1. Import the SDK

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { SDK } from '@vepler/sdk';
  ```

  ```javascript CommonJS theme={null}
  const { SDK } = require('@vepler/sdk');
  ```
</CodeGroup>

### 2. Initialise with API Key

```typescript theme={null}
const vepler = new SDK({
  apiKey: 'vpr_live_abc123...'
});
```

### 3. Make Your First Call

```typescript theme={null}
const response = await vepler.property.getV1PropertyLocationIds({
  locationIds: 'p_0x000123456789'
});

if (response.propertyListResponse) {
  console.log(response.propertyListResponse.result);
}
```

## Environment Variables

<Warning>
  Never hardcode API keys in your source code. Use environment variables instead.
</Warning>

### Create .env File

```bash .env theme={null}
VEPLER_API_KEY=vpr_live_abc123...
```

### Load Environment Variables

<CodeGroup>
  ```typescript Node.js theme={null}
  import dotenv from 'dotenv';
  import { SDK } from '@vepler/sdk';

  dotenv.config();

  const vepler = new SDK({
    apiKey: process.env.VEPLER_API_KEY!
  });
  ```

  ```typescript Next.js theme={null}
  // Environment variables loaded automatically
  import { SDK } from '@vepler/sdk';

  const vepler = new SDK({
    apiKey: process.env.VEPLER_API_KEY!
  });
  ```

  ```typescript Vite theme={null}
  import { SDK } from '@vepler/sdk';

  const vepler = new SDK({
    apiKey: import.meta.env.VITE_VEPLER_API_KEY
  });
  ```
</CodeGroup>

## Framework-Specific Setup

<Accordion title="Next.js">
  ```typescript theme={null}
  // app/lib/vepler.ts
  import { SDK } from '@vepler/sdk';

  const vepler = new SDK({
    apiKey: process.env.VEPLER_API_KEY!
  });

  export default vepler;
  ```

  ```typescript theme={null}
  // app/api/property/route.ts
  import vepler from '@/lib/vepler';

  export async function GET(request: Request) {
    const response = await vepler.property.getV1PropertyLocationIds({
      locationIds: 'p_0x000123456789'
    });
    return Response.json(response.propertyListResponse);
  }
  ```
</Accordion>

<Accordion title="Express.js">
  ```typescript theme={null}
  // src/config/vepler.ts
  import { SDK } from '@vepler/sdk';

  const vepler = new SDK({
    apiKey: process.env.VEPLER_API_KEY!
  });

  export default vepler;
  ```

  ```typescript theme={null}
  // src/routes/property.ts
  import express from 'express';
  import vepler from '../config/vepler';
  const router = express.Router();

  router.get('/property/:id', async (req, res) => {
    try {
      const response = await vepler.property.getV1PropertyLocationIds({
        locationIds: req.params.id
      });
      res.json(response.propertyListResponse);
    } catch (error) {
      res.status(500).json({ error: (error as Error).message });
    }
  });
  ```
</Accordion>

<Accordion title="NestJS">
  ```typescript theme={null}
  // vepler.module.ts
  import { Module, Global } from '@nestjs/common';
  import { SDK } from '@vepler/sdk';

  @Global()
  @Module({
    providers: [
      {
        provide: 'VEPLER_SDK',
        useFactory: () => {
          return new SDK({
            apiKey: process.env.VEPLER_API_KEY!
          });
        }
      }
    ],
    exports: ['VEPLER_SDK']
  })
  export class VeplerModule {}
  ```

  ```typescript theme={null}
  // property.service.ts
  import { Injectable, Inject } from '@nestjs/common';
  import { SDK } from '@vepler/sdk';

  @Injectable()
  export class PropertyService {
    constructor(@Inject('VEPLER_SDK') private vepler: SDK) {}

    async getProperty(id: string) {
      return this.vepler.property.getV1PropertyLocationIds({
        locationIds: id
      });
    }
  }
  ```
</Accordion>

## TypeScript Configuration

The SDK includes TypeScript definitions. Recommended tsconfig settings:

```json tsconfig.json theme={null}
{
  "compilerOptions": {
    "target": "ES2020",
    "module": "commonjs",
    "lib": ["ES2020"],
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "moduleResolution": "node"
  }
}
```

## Troubleshooting

<AccordionGroup>
  <Accordion title="Module not found error">
    Ensure the package is installed:

    ```bash theme={null}
    npm install @vepler/sdk
    ```

    Clear your package manager cache:

    ```bash theme={null}
    npm cache clean --force
    ```
  </Accordion>

  <Accordion title="TypeScript errors">
    Update TypeScript to latest version:

    ```bash theme={null}
    npm install -D typescript@latest
    ```

    Ensure your tsconfig.json has:

    ```json theme={null}
    {
      "compilerOptions": {
        "moduleResolution": "node",
        "esModuleInterop": true
      }
    }
    ```
  </Accordion>

  <Accordion title="API key not working">
    Check that:

    * The key starts with `vpr_live_`
    * No extra spaces or quotes around the key
    * The key has not expired
  </Accordion>
</AccordionGroup>

## Version Management

### Check Installed Version

```bash theme={null}
npm list @vepler/sdk
```

### Update to Latest

```bash theme={null}
npm update @vepler/sdk
```

## Next Steps

<CardGroup cols={2}>
  <Card title="TypeScript Guide" icon="typescript" href="/sdk/typescript">
    Full SDK usage guide
  </Card>

  <Card title="Examples" icon="code" href="/sdk/examples/general">
    See working examples
  </Card>

  <Card title="Authentication" icon="key" href="/authentication">
    Authentication details
  </Card>

  <Card title="API Reference" icon="book" href="/api-reference/introduction">
    Full endpoint documentation
  </Card>
</CardGroup>
