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)
Installation
Choose your preferred package manager:
Verify Installation
Check that the SDK is installed correctly:
Basic Setup
1. Import the SDK
import { SDK } from '@vepler/sdk';
2. Initialise with API Key
const vepler = new SDK({
apiKey: 'vpr_live_abc123...'
});
3. Make Your First Call
const response = await vepler.property.getV1PropertyLocationIds({
locationIds: 'p_0x000123456789'
});
if (response.propertyListResponse) {
console.log(response.propertyListResponse.result);
}
Environment Variables
Never hardcode API keys in your source code. Use environment variables instead.
Create .env File
VEPLER_API_KEY=vpr_live_abc123...
Load Environment Variables
import dotenv from 'dotenv';
import { SDK } from '@vepler/sdk';
dotenv.config();
const vepler = new SDK({
apiKey: process.env.VEPLER_API_KEY!
});
Framework-Specific Setup
// app/lib/vepler.ts
import { SDK } from '@vepler/sdk';
const vepler = new SDK({
apiKey: process.env.VEPLER_API_KEY!
});
export default vepler;
// 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);
}
// src/config/vepler.ts
import { SDK } from '@vepler/sdk';
const vepler = new SDK({
apiKey: process.env.VEPLER_API_KEY!
});
export default vepler;
// 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 });
}
});
// 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 {}
// 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
});
}
}
TypeScript Configuration
The SDK includes TypeScript definitions. Recommended tsconfig settings:
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"lib": ["ES2020"],
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node"
}
}
Troubleshooting
Ensure the package is installed:Clear your package manager cache:
Update TypeScript to latest version:npm install -D typescript@latest
Ensure your tsconfig.json has:{
"compilerOptions": {
"moduleResolution": "node",
"esModuleInterop": true
}
}
Check that:
- The key starts with
vpr_live_
- No extra spaces or quotes around the key
- The key has not expired
Version Management
Check Installed Version
Update to Latest
Next Steps