SDKs
Official client libraries for PropertyBase API.
JavaScript/TypeScript​
Installation​
npm install @propertybase/sdk
# or
yarn add @propertybase/sdk
Usage​
import { PropertyBase } from '@propertybase/sdk';
const client = new PropertyBase({
apiKey: 'YOUR_API_KEY',
// Optional: use sandbox
// baseUrl: 'https://api.sandbox.propertybase.ai/v1'
});
// List properties
const properties = await client.properties.list({
status: 'completed',
limit: 20,
});
// Get single property
const property = await client.properties.get('prop_123');
// Create a lead
const lead = await client.leads.create({
name: 'John Smith',
email: 'john@example.com',
source: 'website',
});
// Update lead stage
await client.leads.updateStage('lead_123', {
stage: 'qualified',
notes: 'Budget confirmed',
});
TypeScript Support​
Full TypeScript definitions included:
import { PropertyBase, Lead, Property, Unit } from '@propertybase/sdk';
const client = new PropertyBase({ apiKey: 'key' });
// Type-safe responses
const lead: Lead = await client.leads.get('lead_123');
const properties: Property[] = await client.properties.list().data;
Python​
Installation​
pip install propertybase
Usage​
from propertybase import PropertyBase
client = PropertyBase(api_key='YOUR_API_KEY')
# List properties
properties = client.properties.list(status='completed', limit=20)
# Get single property
property = client.properties.get('prop_123')
# Create a lead
lead = client.leads.create(
name='John Smith',
email='john@example.com',
source='website'
)
# Update lead stage
client.leads.update_stage('lead_123', stage='qualified', notes='Budget confirmed')
Async Support​
import asyncio
from propertybase import AsyncPropertyBase
async def main():
client = AsyncPropertyBase(api_key='YOUR_API_KEY')
# Async operations
properties = await client.properties.list()
lead = await client.leads.get('lead_123')
asyncio.run(main())
PHP​
Installation​
composer require propertybase/propertybase-php
Usage​
<?php
require_once 'vendor/autoload.php';
use PropertyBase\PropertyBase;
$client = new PropertyBase(['api_key' => 'YOUR_API_KEY']);
// List properties
$properties = $client->properties->list(['status' => 'completed']);
// Get single property
$property = $client->properties->get('prop_123');
// Create a lead
$lead = $client->leads->create([
'name' => 'John Smith',
'email' => 'john@example.com',
'source' => 'website',
]);
// Update lead stage
$client->leads->updateStage('lead_123', [
'stage' => 'qualified',
'notes' => 'Budget confirmed',
]);
Common Operations​
Error Handling​
// JavaScript/TypeScript
import { PropertyBase, ApiError } from '@propertybase/sdk';
try {
const lead = await client.leads.get('lead_123');
} catch (error) {
if (error instanceof ApiError) {
console.log('Error code:', error.code);
console.log('Message:', error.message);
if (error.statusCode === 404) {
// Lead not found
}
}
}
# Python
from propertybase import PropertyBase
from propertybase.exceptions import ApiError, NotFoundError
try:
lead = client.leads.get('lead_123')
except NotFoundError:
print('Lead not found')
except ApiError as e:
print(f'Error: {e.code} - {e.message}')
Pagination​
// JavaScript - Iterate all pages
for await (const property of client.properties.listAll()) {
console.log(property.name);
}
// Or manually paginate
let page = 1;
let hasMore = true;
while (hasMore) {
const result = await client.properties.list({ page, per_page: 100 });
console.log(result.data);
hasMore = page < result.meta.total_pages;
page++;
}
Webhooks​
import { PropertyBase, verifyWebhook } from '@propertybase/sdk';
// Verify webhook signature
app.post('/webhooks', (req, res) => {
const isValid = verifyWebhook(
req.body,
req.headers['x-propertybase-signature'],
req.headers['x-propertybase-timestamp'],
WEBHOOK_SECRET
);
if (!isValid) {
return res.status(401).send('Invalid signature');
}
// Process webhook...
});
SDK Features​
| Feature | JS/TS | Python | PHP |
|---|---|---|---|
| All endpoints | ✓ | ✓ | ✓ |
| TypeScript types | ✓ | - | - |
| Async/await | ✓ | ✓ | - |
| Auto-pagination | ✓ | ✓ | ✓ |
| Webhook verification | ✓ | ✓ | ✓ |
| Rate limit handling | ✓ | ✓ | ✓ |
| Retry logic | ✓ | ✓ | ✓ |
Contributing​
SDKs are open source:
Contributions welcome!