---
title: TypeScript SDK Quickstart | Tabstack
description: 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

## Prerequisites

- **Node.js** >= 20.0.0
- **Package manager**: npm, yarn, pnpm, or bun
- **Tabstack API key** from [console.tabstack.ai](https://console.tabstack.ai)

## Installation

Install the SDK using your preferred package manager:

- [npm](#tab-panel-322)
- [Yarn](#tab-panel-323)
- [pnpm](#tab-panel-324)
- [Bun](#tab-panel-325)

Terminal window

```
npm install @tabstack/sdk
```

Terminal window

```
yarn add @tabstack/sdk
```

Terminal window

```
pnpm add @tabstack/sdk
```

Terminal window

```
bun add @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](https://console.tabstack.ai/)
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

Your API key will only be shown once. Make sure to copy and store it in a secure location.

### 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.

## Your First API Call

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

- [TypeScript](#tab-panel-326)
- [JavaScript](#tab-panel-327)

```
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();
```

```
const Tabstack = require("@tabstack/sdk").default;


// 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)
```

## 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
- **JSON**: Extract structured data matching your schema

### 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 →](./generate)

### 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 →](./automate)

## Quick Example: Extract Structured Data

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

- [TypeScript](#tab-panel-328)
- [JavaScript](#tab-panel-329)

```
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();
```

```
const Tabstack = require("@tabstack/sdk").default;


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();
```

## TypeScript Support

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();
```

## Client Configuration Options

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)
});
```

## Next Steps

Now that you’re up and running:

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

## Need Help?

- **API Reference**: [REST API Documentation](/api/index.md)
- **GitHub**: [TypeScript SDK Repository](https://github.com/Mozilla-Ocho/tabstack-typescript)
- **Documentation**: [docs.tabstack.ai](https://docs.tabstack.ai)
- **Support**: <support@tabstack.ai>
