npm package: @kaziro/api
Description: Kaziro TypeScript API Client
Author: Kaziro Engineering Team, synthpolis
Latest version: 1.0.6

# Kaziro TypeScript API Client

Kaziro is a TypeScript client for interacting with the Kaziro API. It provides a simple and intuitive interface for accessing various endpoints related to users, markets, orders, positions, and wallets.

## Quick Start

### Installation

Install the Kaziro package using npm:

```bash
npm install @kaziro/api
```

### Basic Usage

```typescript
import { Kaziro } from "@kaziro/api";

// Initialize the Kaziro client
const apiKey = process.env.KAZIRO_API_KEY;
const kaziro = new Kaziro({ apiKey });

// Retrieve user profile
const userProfile = await kaziro.user.retrieve();
console.log(`User profile:`, userProfile);

// Retrieve markets
const markets = await kaziro.market.retrieve();
console.log(`Markets:`, markets);

// Place orders
const orders = [{ requestId: "some_id", probability: 0.7 }];
const placedOrders = await kaziro.order.create(orders);
console.log(`Placed orders:`, placedOrders);

// Connect to WebSocket
await kaziro.connectWebsocket();
kaziro.subscribeWebsocket("public:all");
console.log("WebSocket connected and subscribed to 'public:all'");
```

## Features

-   User management (retrieve)
-   Market operations (create, retrieve)
-   Order management (create, retrieve, accept)
-   Position tracking (open positions, history)
-   Wallet information retrieval
-   WebSocket support for real-time updates
-   Bot templates for automated trading

## Detailed Usage

### User Operations

```typescript
// Retrieve user profile
const userProfile = await kaziro.user.retrieve();
```

### Market Operations

```typescript
// Create a new market
const marketDetails = [{ detail: "Market description", size: 100 }];
const createdMarkets = await kaziro.market.create(marketDetails);

// Retrieve markets
const allMarkets = await kaziro.market.retrieve();
const specificMarkets = await kaziro.market.retrieve({ marketIds: ["market_id_1"] });
const openMarkets = await kaziro.market.retrieve({ status: "OPEN" });
```

### Order Operations

```typescript
// Create orders
const orders = [
    { requestId: "id_1", probability: 0.7 },
    { requestId: "id_2", probability: 0.3 },
];
const placedOrders = await kaziro.order.create(orders);

// Retrieve open orders
const allOpenOrders = await kaziro.order.retrieve();
const userOpenOrders = await kaziro.order.retrieve({ filterUser: true });

// Accept orders
const acceptedOrders = await kaziro.order.accept(["order_id_1", "order_id_2"]);

// Request default replies
const defaultReplies = await kaziro.order.requestDefaultReplies(["order_id_1"]);
```

### Position Operations

```typescript
// Get open positions
const openPositions = await kaziro.position.retrieve({ status: "ACTIVE" });

// Get position history
const positionHistory = await kaziro.position.retrieve({ status: "CLOSED" });
```

### Wallet Operations

```typescript
// Retrieve wallet information
const walletInfo = await kaziro.wallet.retrieve();
```

### WebSocket Usage

```typescript
// Connect to WebSocket
await kaziro.connectWebsocket();

// Subscribe to a channel
kaziro.subscribeWebsocket("public:all");
```

### Bot Templates

```typescript
// Use the base market maker bot
await kaziro.template.baseMarketMaker();
```

## Development

To set up the development environment:

1. Clone the repository:

```bash
git clone https://github.com/kazirocom/typescript-client.git
cd typescript-client
```

2. Install dependencies:

```bash
npm install
```

3. Build the package:

```bash
npm run build
```

4. Run tests:

```bash
npm test
```

## Contributing

We welcome contributions to the Kaziro TypeScript client. Please feel free to submit issues, fork the repository and send pull requests!

## License

This project is licensed under the MIT License - see the LICENSE file for details.

## Support

For support, please contact the Kaziro team at support@kaziro.xyz or open an issue on the GitHub repository.