dataTamer logodataTamer
Back to Tutorials
Advanced25 min read

Using the API & SDK

Generate API keys, stream data programmatically, and integrate dataTamer into your applications.

What You'll Learn

How to generate and manage API keys
Using the dataTamer REST API
Working with the official SDK
Streaming data programmatically
Performing RAG searches via API
Building custom integrations
1

Generate an API Key

  1. 1. Click on your profile icon in the top-right corner
  2. 2. Select "Settings" from the dropdown
  3. 3. Navigate to the "API Keys" tab
  4. 4. Click "Generate New API Key"
  5. 5. Give your key a descriptive name (e.g., "Production Server")
  6. 6. Select permissions: Read, Write, or Admin
  7. 7. Click "Create"

⚠️ Important: Copy your API key immediately! You won't be able to see it again. Store it securely in environment variables.

2

Store Your API Key Securely

Store your API key in environment variables:

# .env file
DATATAMER_API_KEY=your_api_key_here
DATATAMER_API_URL=https://app.datatamer.ai/api

Add .env to your .gitignore file

3

Using the REST API

All API requests require authentication using Bearer token:

curl -X GET https://app.datatamer.ai/api/v1/topics \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json"

Common Endpoints:

  • GET /api/v1/topics - List topics
  • GET /api/v1/datasources - List datasources
  • POST /api/v1/tamed-data/:id/stream - Stream data
  • POST /api/v1/tamed-data/:id/search - RAG search
4

Install the SDK

JavaScript/TypeScript (Node.js):

npm install @datatamer/sdk
# or
yarn add @datatamer/sdk

Python:

pip install datatamer-sdk
5

Initialize the SDK

JavaScript/TypeScript:

import { DataTamerClient } from '@datatamer/sdk';

const client = new DataTamerClient({
  apiKey: process.env.DATATAMER_API_KEY,
  apiUrl: 'https://app.datatamer.ai/api'
});

Python:

from datatamer import DataTamerClient
import os

client = DataTamerClient(
    api_key=os.getenv('DATATAMER_API_KEY'),
    api_url='https://app.datatamer.ai/api'
)
6

Stream Data Programmatically

JavaScript Example:

const tamedDataId = 'td_789';

// Stream a single record
await client.tamedData.stream(tamedDataId, {
  event: 'user_signup',
  user_id: '12345',
  email: '[email protected]',
  timestamp: new Date().toISOString()
});

// Stream multiple records
const records = [
  { event: 'page_view', page: '/home' },
  { event: 'purchase', product: 'Widget' }
];

await client.tamedData.streamBatch(tamedDataId, records);

Python Example:

tamed_data_id = 'td_789'

# Stream a single record
client.tamed_data.stream(tamed_data_id, {
    'event': 'user_signup',
    'user_id': '12345',
    'email': '[email protected]'
})

# Stream multiple records
records = [
    {'event': 'page_view', 'page': '/home'},
    {'event': 'purchase', 'product': 'Widget'}
]

client.tamed_data.stream_batch(tamed_data_id, records)
7

Perform RAG Search

JavaScript Example:

const results = await client.tamedData.search(tamedDataId, {
  query: 'What are the top features requested by users?',
  topK: 10,
  includeAnswer: true
});

console.log('AI Answer:', results.answer);
console.log('Source Documents:', results.results);

Python Example:

results = client.tamed_data.search(tamed_data_id,
    query='What are the top features requested?',
    top_k=10,
    include_answer=True
)

print('AI Answer:', results['answer'])
print('Source Documents:', results['results'])
8

Best Practices

  • Environment Variables: Never hardcode API keys
  • Error Handling: Implement retry logic with exponential backoff
  • Rate Limiting: Respect API rate limits (check response headers)
  • Batch Operations: Use batch endpoints for streaming multiple records
  • Key Rotation: Rotate API keys regularly (every 90 days)
  • Server-Side Only: Never expose API keys in client-side code

Congratulations!

You've completed all dataTamer tutorials! You now know how to upload data, connect databases, search code, create rules, and integrate via API.