Skip to content
Start free

TypeScript SDK Quickstart

Get up and running with the Tabstack TypeScript SDK in minutes. Installation, authentication, and your first API call.

Get up and running with the Tabstack TypeScript SDK in minutes. This guide will walk you through installation, authentication, and your first API call.

SDK Version: 2.6.1

  • Node.js >= 20.0.0
  • Package manager: npm, yarn, pnpm, or bun
  • Tabstack API key from console.tabstack.ai

Install the SDK using your preferred package manager:

Terminal window
npm install @tabstack/sdk

Create and Setup Your API Key

Before you can start using Tabstack API, you’ll need to create an API key and set it up in your environment.

1. Create Your API Key

  1. Visit the Tabstack Console
  2. Sign in to your account (or create one if you haven’t already)
  3. Navigate to the API Keys section and click the “Manage API Keys”
  4. Once you are on the API Keys page, Click “Create New API Key”
  5. Give your key a descriptive name (e.g., “Development”, “Production”) and click the “Create API Key”
  6. Copy the generated API key and store it securely

2. Set Up Environment Variable

For security and convenience, we recommend storing your API key as an environment variable rather than hardcoding it in your scripts.

macOS/Linux
Terminal window
# 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")

3. Verify Your Setup

Test that your environment variable is set correctly:

macOS/Linux/Windows (Git Bash):

Terminal window
echo $TABSTACK_API_KEY

Windows (Command Prompt):

Terminal window
echo %TABSTACK_API_KEY%

Windows (PowerShell):

Terminal window
echo $env:TABSTACK_API_KEY

You should see your API key printed in the terminal.

Let’s start with a simple markdown extraction to verify your setup:

import Tabstack from "@tabstack/sdk";
// Initialize the client
const client = new Tabstack({
apiKey: process.env.TABSTACK_API_KEY!,
});
// Extract markdown from a URL
async function extractMarkdown() {
try {
const result = await client.extract.markdown({
url: "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)

The SDK provides four main operators for working with web content:

Ask a question and get back a cited answer from live sources. The call always streams: progress events arrive first, then the complete event carries the report and the pages it cited.

import Tabstack from "@tabstack/sdk";
const client = new Tabstack();
const stream = await client.agent.research({
query: "What are the main approaches to browser automation for AI agents?",
mode: "fast",
});
for await (const event of stream) {
if (event.event === "error") {
throw new Error(event.data.error.message);
}
if (event.event === "complete") {
console.log(event.data.report);
for (const page of event.data.metadata.citedPages ?? []) {
console.log(`- ${page.title ?? "(untitled)"}: ${page.url}`);
}
}
}

Research guide →

Convert web pages to structured data:

  • Markdown: Convert HTML to clean Markdown format
  • JSON: Extract structured data matching your schema

Transform web content using AI:

  • Summarize and analyze content
  • Categorize and tag data
  • Perform sentiment analysis
  • Extract key insights with custom instructions

Generate reference →

Execute browser automation tasks with natural language:

  • Web data collection with real-time updates
  • Form filling and submission
  • Multi-step workflows
  • Streaming progress events

Automate reference →

Here’s a more advanced example that extracts structured data from a web page:

import Tabstack from "@tabstack/sdk";
const client = 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 client.extract.json({
url: "https://news.ycombinator.com",
json_schema: schema,
});
console.log(result.stories);
} catch (error) {
console.error("Error:", error.message);
}
}
extractStories();

The SDK is fully type-safe with complete TypeScript definitions:

import Tabstack, { ExtractJsonResponse } 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 client = new Tabstack({ apiKey: process.env.TABSTACK_API_KEY! });
async function getStories() {
const result = (await client.extract.json({
url: "https://news.ycombinator.com",
json_schema: schema,
})) as HackerNewsData;
// TypeScript knows the structure of result
result.stories.forEach((story) => {
console.log(story.title); // Type-safe access
});
}
getStories();

The SDK client accepts several configuration options:

import Tabstack from "@tabstack/sdk";
const client = new Tabstack({
apiKey: process.env.TABSTACK_API_KEY!,
timeout: 60000, // Request timeout in milliseconds (default: 60000)
maxRetries: 2, // Number of retries for failed requests (default: 2)
});

Now that you’re up and running:

  1. Generate Features: Discover AI-powered content transformation and analysis
  2. Automate Features: Execute complex browser automation tasks with streaming updates
  3. Error Handling: Build robust applications with proper error handling