Getting Started with the AskBiz SDK
How to install and use the official AskBiz Node.js and Python SDKs — covering setup, authentication, and your first API call in under 10 minutes.
Available SDKs
AskBiz provides official SDKs for the two most common server-side languages:
- Node.js / TypeScript:
@askbiz/sdk— available on npm - Python:
askbiz-sdk— available on PyPI
Both SDKs wrap the REST API with typed interfaces, automatic retry logic, and built-in request signing. They are open source — view the source and contribute at github.com/askbiz.
For other languages, use the REST API directly — the SDK source code serves as implementation reference.
Node.js quickstart
Install:
```bash
npm install @askbiz/sdk
```
Initialise:
```typescript
import { AskBiz } from '@askbiz/sdk';
const client = new AskBiz({
apiKey: process.env.ASKBIZ_API_KEY,
});
```
First API call — get revenue for last 30 days:
```typescript
const revenue = await client.metrics.revenue({
period: 'last_30_days',
channel: 'all',
});
console.log(revenue.total); // e.g. 42500.00
console.log(revenue.currency); // 'GBP'
```
Ask an AI question:
```typescript
const answer = await client.ai.query({
question: 'What is my gross margin this month?',
});
console.log(answer.text);
```
Python quickstart
Install:
```bash
pip install askbiz-sdk
```
Initialise:
```python
from askbiz import AskBiz
import os
client = AskBiz(api_key=os.environ['ASKBIZ_API_KEY'])
```
First API call — get top products:
```python
products = client.products.top(
period='last_30_days',
limit=10,
sort_by='revenue'
)
for product in products:
print(f"{product.name}: £{product.revenue:.2f}")
```
Error handling:
```python
from askbiz.exceptions import AskBizRateLimitError, AskBizAuthError
try:
result = client.metrics.revenue(period='last_7_days')
except AskBizRateLimitError as e:
print(f'Rate limited. Retry after {e.retry_after} seconds.')
except AskBizAuthError:
print('Invalid API key.')
```
SDK configuration options
Both SDKs support the following configuration options:
```typescript
const client = new AskBiz({
apiKey: 'ak_live_...',
baseUrl: 'https://api.askbiz.co/v1', // override for sandbox: /sandbox/v1
timeout: 30000, // request timeout in ms (default: 30000)
maxRetries: 3, // automatic retry attempts on 429 and 5xx (default: 3)
retryDelay: 1000, // base delay between retries in ms (default: 1000)
});
```
For local development, set baseUrl to https://api.askbiz.co/sandbox/v1 to use the sandbox environment.