Local Development Setup

Set up a local development environment to build integrations with the TyneBase API.

Read time:10 minUpdated:2026-01-10

Local Development Setup

Set up a local environment to develop and test TyneBase API integrations.

Prerequisites

  • Node.js 20+ or Python 3.11+
  • Docker (optional, for local API mock)
  • Git

Quick start with SDK

JavaScript/TypeScript

# Create new project
mkdir my-tynebase-integration
cd my-tynebase-integration
npm init -y

# Install SDK
npm install @tynebase/sdk typescript ts-node

Create index.ts:

import { TyneBase } from '@tynebase/sdk';

const client = new TyneBase({
  apiKey: process.env.TYNEBASE_API_KEY,
  baseUrl: 'https://api.tynebase.com/v1', // or local mock
});

async function main() {
  // List documents
  const docs = await client.documents.list({ limit: 10 });
  console.log('Documents:', docs.data);

  // Create a document
  const newDoc = await client.documents.create({
    title: 'Created via API',
    content: '# Hello World\n\nThis was created programmatically.',
    state: 'draft',
  });
  console.log('Created:', newDoc.data.id);

  // AI Search
  const answer = await client.ask('How do I get started?');
  console.log('Answer:', answer.data.answer);
}

main().catch(console.error);

Run with:

TYNEBASE_API_KEY=your_key npx ts-node index.ts

Python

# Create virtual environment
python -m venv venv
source venv/bin/activate  # or venv\Scripts\activate on Windows

# Install SDK
pip install tynebase

Create main.py:

import os
from tynebase import TyneBase

client = TyneBase(
    api_key=os.environ['TYNEBASE_API_KEY'],
    base_url='https://api.tynebase.com/v1'
)

# List documents
docs = client.documents.list(limit=10)
for doc in docs.data:
    print(f"- {doc.title}")

# Create document
new_doc = client.documents.create(
    title="Created via Python",
    content="# Hello\n\nCreated with Python SDK",
    state="draft"
)
print(f"Created: {new_doc.data.id}")

# AI Search
answer = client.ask("What is TyneBase?")
print(f"Answer: {answer.data.answer}")

Local API Mock Server

For offline development, run a local mock:

# Clone mock server
git clone https://github.com/tynebase/api-mock
cd api-mock

# Install and run
npm install
npm start

Mock server runs at http://localhost:3001.

Configure SDK:

const client = new TyneBase({
  apiKey: 'test-key',
  baseUrl: 'http://localhost:3001/v1',
});

Environment Variables

Create .env file:

# API Configuration
TYNEBASE_API_KEY=your_api_key_here
TYNEBASE_BASE_URL=https://api.tynebase.com/v1

# For tenant-specific access
TYNEBASE_TENANT_ID=your_tenant_id

# Webhook development
TYNEBASE_WEBHOOK_SECRET=your_webhook_secret

Webhook Development

Use ngrok for local webhook testing:

# Install ngrok
npm install -g ngrok

# Start local server
node webhook-server.js  # listening on port 3000

# Expose via ngrok
ngrok http 3000

Register the ngrok URL as your webhook endpoint in TyneBase settings.

Testing

Unit Tests

import { TyneBase } from '@tynebase/sdk';
import { mockClient } from '@tynebase/sdk/testing';

describe('My Integration', () => {
  const client = mockClient();

  it('should list documents', async () => {
    client.documents.list.mockResolvedValue({
      data: [{ id: 'doc_1', title: 'Test' }],
    });

    const result = await client.documents.list();
    expect(result.data).toHaveLength(1);
  });
});

Integration Tests

// Use a test API key with limited permissions
const testClient = new TyneBase({
  apiKey: process.env.TYNEBASE_TEST_API_KEY,
});

describe('Integration Tests', () => {
  it('should create and delete document', async () => {
    const doc = await testClient.documents.create({
      title: 'Test Doc',
      content: 'Test content',
    });
    
    expect(doc.data.id).toBeDefined();
    
    await testClient.documents.delete(doc.data.id);
  });
});

Rate Limit Handling

The SDK automatically handles rate limits:

const client = new TyneBase({
  apiKey: 'your_key',
  retryOnRateLimit: true,
  maxRetries: 3,
});