TypeScript SDK Quickstart
Get up and running with the TABStack TypeScript SDK in minutes. This guide will walk you through installation, authentication, and your first API call.
Prerequisites
- Node.js >= 20.0.0
- Package manager: npm, yarn, pnpm, or bun
- TABStack API key from console.tabstack.ai
Installation
Install the SDK using your preferred package manager:
- npm
- Yarn
- pnpm
- Bun
npm install @tabstack/sdk
yarn add @tabstack/sdk
pnpm add @tabstack/sdk
bun add @tabstack/sdk
Get Your API Key
Before you can start using the SDK, you'll need to create an API key:
- Visit the TABStack Console
- Sign in to your account (or create one if you haven't already)
- Navigate to the API Keys section and click "Manage API Keys"
- Click "Create New API Key"
- Give your key a descriptive name (e.g., "Development", "Production")
- Copy the generated API key and store it securely
⚠️ Important: Your API key will only be shown once. Make sure to copy and store it in a secure location.
Set Up Environment Variable
For security and convenience, store your API key as an environment variable:
macOS/Linux:
# Add to your shell profile (~/.bashrc, ~/.zshrc, or ~/.bash_profile)
export TABSTACK_API_KEY="your_api_key_here"
# Or set it temporarily for the current session
export TABSTACK_API_KEY="your_api_key_here"
# Reload your shell or run:
source ~/.bashrc # or ~/.zshrc
Windows (Command Prompt):
# Set temporarily for current session
set TABSTACK_API_KEY=your_api_key_here
# Set permanently (requires restart)
setx TABSTACK_API_KEY "your_api_key_here"
Windows (PowerShell):
# Set temporarily for current session
$env:TABSTACK_API_KEY = "your_api_key_here"
# Set permanently for current user
[Environment]::SetEnvironmentVariable("TABSTACK_API_KEY", "your_api_key_here", "User")
Your First API Call
Let's start with a simple markdown extraction to verify your setup:
- TypeScript
- JavaScript
import { TABStack } from '@tabstack/sdk';
// Initialize the client
const tabs = new TABStack({
apiKey: process.env.TABSTACK_API_KEY!
});
// Extract markdown from a URL
async function extractMarkdown() {
try {
const result = await tabs.extract.markdown('https://example.com');
console.log(result.content);
} catch (error) {
console.error('Error:', error.message);
}
}
extractMarkdown();
const { TABStack } = require('@tabstack/sdk');
// Initialize the client
const tabs = new TABStack({
apiKey: process.env.TABSTACK_API_KEY
});
// Extract markdown from a URL
async function extractMarkdown() {
try {
const result = await tabs.extract.markdown('https://example.com');
console.log(result.content);
} catch (error) {
console.error('Error:', error.message);
}
}
extractMarkdown();
Response:
---
title: Example Domain
description: Example Domain
url: https://example.com
type: website
---
# Example Domain
This domain is for use in illustrative examples in documents. You may use this
domain in literature without prior coordination or asking for permission.
[More information...](https://www.iana.org/domains/example)
Core Features
The SDK provides three main operators for working with web content:
Extract
Convert web pages to structured data:
- Markdown: Convert HTML to clean Markdown format
- Schema: Auto-generate JSON schemas from web content
- JSON: Extract structured data matching your schema
Learn more about Extract features →
Generate
Transform web content using AI:
- Summarize and analyze content
- Categorize and tag data
- Perform sentiment analysis
- Extract key insights with custom instructions
Learn more about Generate features →
Automate
Execute browser automation tasks with natural language:
- Web scraping with real-time updates
- Form filling and submission
- Multi-step workflows
- Streaming progress events
Learn more about Automate features →
Quick Example: Extract Structured Data
Here's a more advanced example that extracts structured data from a web page:
- TypeScript
- JavaScript
import { TABStack } from '@tabstack/sdk';
const tabs = new TABStack({
apiKey: process.env.TABSTACK_API_KEY!
});
// Define the data structure you want
const schema = {
type: 'object',
properties: {
stories: {
type: 'array',
items: {
type: 'object',
properties: {
title: { type: 'string' },
points: { type: 'number' },
author: { type: 'string' }
},
required: ['title', 'points', 'author']
}
}
},
required: ['stories']
};
// Extract data matching the schema
async function extractStories() {
try {
const result = await tabs.extract.json('https://news.ycombinator.com', schema);
console.log(result.data.stories);
} catch (error) {
console.error('Error:', error.message);
}
}
extractStories();
const { TABStack } = require('@tabstack/sdk');
const tabs = new TABStack({
apiKey: process.env.TABSTACK_API_KEY
});
// Define the data structure you want
const schema = {
type: 'object',
properties: {
stories: {
type: 'array',
items: {
type: 'object',
properties: {
title: { type: 'string' },
points: { type: 'number' },
author: { type: 'string' }
},
required: ['title', 'points', 'author']
}
}
},
required: ['stories']
};
// Extract data matching the schema
async function extractStories() {
try {
const result = await tabs.extract.json('https://news.ycombinator.com', schema);
console.log(result.data.stories);
} catch (error) {
console.error('Error:', error.message);
}
}
extractStories();
TypeScript Support
The SDK is fully type-safe with complete TypeScript definitions:
import { TABStack, JsonResponse } from '@tabstack/sdk';
// Define your data type
interface Story {
title: string;
points: number;
author: string;
}
interface HackerNewsData {
stories: Story[];
}
// Define the schema
const schema = {
type: 'object',
properties: {
stories: {
type: 'array',
items: {
type: 'object',
properties: {
title: { type: 'string' },
points: { type: 'number' },
author: { type: 'string' }
},
required: ['title', 'points', 'author']
}
}
},
required: ['stories']
};
// Get type-safe responses
const tabs = new TABStack({ apiKey: process.env.TABSTACK_API_KEY! });
async function getStories() {
const result: JsonResponse<HackerNewsData> = await tabs.extract.json(
'https://news.ycombinator.com',
schema
);
// TypeScript knows the structure of result.data
result.data.stories.forEach(story => {
console.log(story.title); // Type-safe access
});
}
getStories();
Next Steps
Now that you're up and running:
- Extract Features: Learn how to extract markdown, generate schemas, and pull structured JSON data
- Generate Features: Discover AI-powered content transformation and analysis
- Automate Features: Execute complex browser automation tasks with streaming updates
- Error Handling: Build robust applications with proper error handling
Need Help?
- API Reference: REST API Documentation
- GitHub: TypeScript SDK Repository
- Documentation: docs.tabstack.ai