SDKs
Official client libraries for diil.ai API.
JavaScript/TypeScript​
Installation​
npm install @diil-ai/sdk
# or
yarn add @diil-ai/sdk
Usage​
import { diil.ai } from '@diil-ai/sdk';
const client = new diil.ai({
apiKey: 'YOUR_API_KEY',
// Optional: use sandbox
// baseUrl: 'https://api.sandbox.diil.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 { diil.ai, Lead, Property, Unit } from '@diil-ai/sdk';
const client = new diil.ai({ 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 diil-ai
Usage​
from diil-ai import diil.ai
client = diil.ai(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 diil-ai import Asyncdiil.ai
async def main():
client = Asyncdiil.ai(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 diil-ai/diil-ai-php
Usage​
<?php
require_once 'vendor/autoload.php';
use diil.ai\diil.ai;
$client = new diil.ai(['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 { diil.ai, ApiError } from '@diil-ai/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 diil-ai import diil.ai
from diil-ai.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 { diil.ai, verifyWebhook } from '@diil-ai/sdk';
// Verify webhook signature
app.post('/webhooks', (req, res) => {
const isValid = verifyWebhook(
req.body,
req.headers['x-diil-ai-signature'],
req.headers['x-diil-ai-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!