Installation
Install the Taruvi SDK in your development environment with your preferred package manager.
Choose Your Language
- Python
- JavaScript
Python SDK
Requirements
- Python: 3.10 or higher
- Operating Systems: Linux, macOS, Windows
Installation
Choose your preferred package manager:
- pip
- Poetry
- Pipenv
pip install taruvi
poetry add taruvi
pipenv install taruvi
Verify Installation
import taruvi
print(f"Taruvi SDK version: {taruvi.__version__}")
Initializing the Client
from taruvi import Client
# Create client with API credentials
client = Client(
api_url="https://api.taruvi.cloud",
app_slug="my-app"
)
# Check client is ready
print(f"Client initialized for app: {client.config.app_slug}")
Configuration Options
The Python SDK supports multiple configuration methods:
1. Direct Parameters (Recommended for Scripts)
from taruvi import Client
client = Client(
api_url="https://api.taruvi.cloud",
app_slug="my-app",
timeout=60,
max_retries=5
)
2. Environment Variables
Create a .env file in your project root:
# .env file
TARUVI_API_URL=https://api.taruvi.cloud
TARUVI_APP_SLUG=my-app
TARUVI_MODE=sync
TARUVI_TIMEOUT=60
TARUVI_MAX_RETRIES=5
# Optional: Authentication credentials
TARUVI_JWT=your-jwt-token
TARUVI_API_KEY=your-api-key
Then load with python-dotenv:
from dotenv import load_dotenv
from taruvi import Client
# Load environment variables
load_dotenv()
# Client automatically reads from environment
client = Client()
3. Runtime Detection (Inside Taruvi Functions)
When running inside a Taruvi function, the SDK auto-configures:
from taruvi import Client
# No configuration needed - auto-detects function runtime
client = Client()
# Authentication is automatically inherited
users = client.database.query("users").get()
Async Mode
For async/await support:
from taruvi import Client
import asyncio
async def main():
# Create async client
client = Client(
mode='async',
api_url="https://api.taruvi.cloud",
app_slug="my-app"
)
# Authenticate
auth_client = client.auth.signInWithPassword(
username="alice@example.com",
password="secret123"
)
# Use async operations
users = await auth_client.database.query("users").get()
# Close connection
await auth_client.close()
asyncio.run(main())
Python SDK supports both sync and async patterns. Use mode='async' for async operations.
JavaScript/TypeScript SDK
Requirements
- Node.js: 18.0 or higher (for server-side)
- Browsers: Modern browsers (Chrome, Firefox, Safari, Edge)
- TypeScript: Optional but recommended
Installation
Choose your preferred package manager:
- npm
- Yarn
- pnpm
npm install @taruvi/sdk
yarn add @taruvi/sdk
pnpm add @taruvi/sdk
Verify Installation
import { Client } from '@taruvi/sdk'
console.log('Taruvi SDK installed successfully!')
Initializing the Client
import { Client } from '@taruvi/sdk'
// Create client with API credentials
const client = new Client({
apiKey: "site-api-key",
appSlug: "my-app",
baseUrl: "https://site.taruvi.cloud"
})
console.log(`Client initialized for app: ${client.config.appSlug}`)
Configuration Options
The JavaScript SDK supports multiple configuration methods:
1. Direct Parameters (Recommended)
import { Client } from '@taruvi/sdk'
const client = new Client({
apiKey: "site-api-key",
appSlug: "my-app",
baseUrl: "https://site.taruvi.cloud",
deskUrl: "https://desk.taruvi.cloud", // Optional: Login page URL
token: "existing-jwt-token" // Optional: Pre-existing token
})
2. Environment Variables (Vite)
For Vite-based projects (Vue, React, etc.):
# .env file
VITE_TARUVI_API_KEY=site-api-key
VITE_TARUVI_APP_SLUG=my-app
VITE_TARUVI_BASE_URL=https://site.taruvi.cloud
import { Client } from '@taruvi/sdk'
const client = new Client({
apiKey: import.meta.env.VITE_TARUVI_API_KEY,
appSlug: import.meta.env.VITE_TARUVI_APP_SLUG,
baseUrl: import.meta.env.VITE_TARUVI_BASE_URL
})
3. Environment Variables (Next.js)
For Next.js projects:
# .env.local file
NEXT_PUBLIC_TARUVI_API_KEY=site-api-key
NEXT_PUBLIC_TARUVI_APP_SLUG=my-app
NEXT_PUBLIC_TARUVI_BASE_URL=https://site.taruvi.cloud
import { Client } from '@taruvi/sdk'
const client = new Client({
apiKey: process.env.NEXT_PUBLIC_TARUVI_API_KEY!,
appSlug: process.env.NEXT_PUBLIC_TARUVI_APP_SLUG!,
baseUrl: process.env.NEXT_PUBLIC_TARUVI_BASE_URL!
})
4. Environment Variables (Node.js)
For Node.js server applications:
# .env file
TARUVI_API_KEY=site-api-key
TARUVI_APP_SLUG=my-app
TARUVI_BASE_URL=https://site.taruvi.cloud
import 'dotenv/config'
import { Client } from '@taruvi/sdk'
const client = new Client({
apiKey: process.env.TARUVI_API_KEY!,
appSlug: process.env.TARUVI_APP_SLUG!,
baseUrl: process.env.TARUVI_BASE_URL!
})
Using Service Modules
The JavaScript SDK uses a modular architecture:
import { Client, Database, Storage, Functions } from '@taruvi/sdk'
// Create client
const client = new Client({
apiKey: "site-api-key",
appSlug: "my-app",
baseUrl: "https://site.taruvi.cloud"
})
// Instantiate service modules
const database = new Database(client)
const storage = new Storage(client)
const functions = new Functions(client)
// Use modules
const users = await database.from("users").execute()
const result = await functions.execute("my-function")
TypeScript Support
The SDK is written in TypeScript with full type definitions:
import { Client, Database, type DatabaseResponse } from '@taruvi/sdk'
const client = new Client({...})
const db = new Database(client)
// TypeScript knows the response type
const users: DatabaseResponse = await db.from("users").execute()
// Type-safe method calls with autocomplete
const filtered = await db
.from("users")
.filter({ is_active: true }) // TypeScript validates filter structure
.execute()
IDE Setup
Visual Studio Code
For the best development experience with VS Code:
Python:
- Install the Python extension
- Enable type checking in
settings.json:
{
"python.analysis.typeCheckingMode": "basic",
"python.analysis.autoImportCompletions": true
}
JavaScript/TypeScript:
- Install the TypeScript extension (built-in)
- Enable import suggestions:
{
"typescript.suggest.autoImports": true,
"javascript.suggest.autoImports": true
}
PyCharm / WebStorm
PyCharm (Python):
- Type hints are automatically recognized
- Enable "Enable type annotations" in Settings → Editor → General → Code Completion
WebStorm (JavaScript):
- TypeScript support is built-in
- Enable "TypeScript" language service
Troubleshooting
Python Issues
Import Error: "No module named 'taruvi'"
Solution: Ensure you're using the correct Python environment:
# Check Python version
python --version # Should be 3.10+
# Reinstall in current environment
pip install --force-reinstall taruvi
Type Hint Errors in IDE
Solution: Update your IDE's Python language server or install type stub packages:
pip install types-requests
SSL Certificate Errors
Solution: Update your certificates or specify a custom certificate:
import os
os.environ['REQUESTS_CA_BUNDLE'] = '/path/to/cacert.pem'
JavaScript Issues
Module Resolution Errors
Solution: Ensure your package.json has the correct module type:
{
"type": "module"
}
Or use CommonJS require:
const { Client } = require('@taruvi/sdk')
TypeScript Errors
Solution: Ensure TypeScript is configured correctly in tsconfig.json:
{
"compilerOptions": {
"moduleResolution": "node",
"esModuleInterop": true,
"strict": true
}
}
Browser CORS Errors
Solution: CORS must be configured on the Taruvi server. Contact your administrator or check CORS documentation.
Upgrading
Check Current Version
- Python
- JavaScript
pip show taruvi
npm list @taruvi/sdk
Upgrade to Latest Version
- Python
- JavaScript
pip install --upgrade taruvi
npm update @taruvi/sdk
Breaking Changes
Check the CHANGELOG for breaking changes before upgrading major versions.
Next Steps
Now that you have the SDK installed:
- Quickstart Guide → - Build your first application in 5 minutes
- Authentication → - Learn about authentication methods
- API Reference → - Explore detailed API documentation with SDK examples
Related Documentation
- SDK Overview - SDK features and capabilities
- Getting Started - Platform introduction
- API Reference - REST API documentation