# Overview

## Opinion CLOB TypeScript SDK

Welcome to the official documentation for the **Opinion CLOB TypeScript SDK** - a TypeScript library for interacting with Opinion Labs' prediction markets via the Central Limit Order Book (CLOB) API.

{% hint style="warning" %}
**Technical Preview**: TypeScript SDK Version 0.5.2 features BNB Chain support. While fully functional and tested, we recommend thorough testing before production use.

To request SDK/API access, please kindly fill out this [short application form](https://docs.google.com/forms/d/d/1h7gp8UffZeXzYQ-lv4jcou9PoRNOqMAQhyW4IwZDnII).

*API Key can be used for Opinion OpenAPI, Opinion Websocket, and Opinion CLOB SDK*
{% endhint %}

### What is Opinion CLOB TypeScript SDK?

The Opinion CLOB TypeScript SDK provides a TypeScript interface for building applications on top of Opinion prediction market infrastructure. It enables developers to:

* **Query market data** - Access real-time market information, prices, and orderbooks
* **Execute trades** - Place market and limit orders with EIP712 signing
* **Manage positions** - Track balances, positions, and trading history
* **Interact with smart contracts** - Split, merge, and redeem tokens on BNB Chain blockchain

### Key Features

#### Production-Ready

* **Type-safe** - Full TypeScript types and interfaces
* **Well-tested** - Test suite with 95%+ coverage
* **Reliable** - Built on industry-standard libraries (viem)
* **Documented** - Extensive documentation with examples

#### Performance Optimized

* **Smart caching** - Configurable TTL for market data and quote tokens
* **Batch operations** - Place or cancel multiple orders efficiently
* **Gas optimization** - Minimal on-chain transactions

#### Secure by Design

* **EIP712 signing** - Industry-standard typed data signatures
* **Multi-sig support** - Gnosis Safe integration for institutional users
* **Private key safety** - Keys never leave your environment

#### Blockchain Support

* **BNB Chain Mainnet** (Chain ID: 56)

### Use Cases

#### Trading Applications

Build automated trading bots, market-making applications, or custom trading interfaces.

{% code title="example.ts" %}

```typescript
import { Client, DEFAULT_API_HOST, CHAIN_ID_BNB_MAINNET, OrderSide, OrderType } from '@opinion-labs/opinion-clob-sdk';

const client = new Client({ host: DEFAULT_API_HOST, apiKey: 'your_key', ... });

// Place a limit order
const result = await client.placeOrder({
  marketId: 123,
  tokenId: 'token_yes',
  side: OrderSide.BUY,
  orderType: OrderType.LIMIT_ORDER,
  price: '0.55',
  makerAmountInQuoteToken: '100',
});
```

{% endcode %}

#### Market Analytics

Aggregate and analyze market data for research or monitoring dashboards.

{% code title="analytics.ts" %}

```typescript
// Get all active markets
const markets = await client.getMarkets({ status: TopicStatusFilter.ACTIVATED, limit: 100 });

// Analyze orderbook depth
const orderbook = await client.getOrderbook('token_123');
console.log('Orderbook:', orderbook.result);
```

{% endcode %}

#### Portfolio Management

Track positions and balances across multiple markets.

{% code title="portfolio.ts" %}

```typescript
// Get user positions
const positions = await client.getMyPositions({ limit: 50 });

// Get balances
const balances = await client.getMyBalances();

// Get trade history
const trades = await client.getMyTrades({ marketId: 123 });
```

{% endcode %}

### Architecture

The Opinion CLOB TypeScript SDK is built with a modular architecture:

```
+---------------------------------------------+
|          Application Layer                   |
|        (Your TypeScript Code)                |
+--------------+------------------------------+
               |
+--------------v------------------------------+
|         Opinion CLOB SDK                     |
|  +--------------+   +-----------------+      |
|  | Client API   |   | Contract Caller |      |
|  | (REST)       |   | (Blockchain)    |      |
|  +------+-------+   +----------+------+      |
+---------+----------------------+-------------+
          |                      |
+---------v----------+  +-------v------------+
|  Opinion API       |  |     Blockchain     |
|  (CLOB Exchange)   |  |  (Smart Contracts) |
+--------------------+  +--------------------+
```

### Quick Links

* [Installation Guide](/developer-guide/opinion-clob-typescript-sdk/getting-started/installation.md)
* [Quick Start](/developer-guide/opinion-clob-typescript-sdk/getting-started/quick-start.md)
* [Core Concepts](/developer-guide/opinion-clob-typescript-sdk/core-concepts.md)
* [API Reference](/developer-guide/opinion-clob-typescript-sdk/api-references.md)
* [FAQ](/developer-guide/opinion-clob-typescript-sdk/support/faq.md)

Ready to get started? Head to the Installation Guide to begin building with Opinion CLOB TypeScript SDK!


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.opinion.trade/developer-guide/opinion-clob-typescript-sdk/overview.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
