1.0.1 • Published 9 months ago

@kaziro/api v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

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:

npm install @kaziro/api

Basic Usage

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

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

Market Operations

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

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

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

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

Wallet Operations

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

WebSocket Usage

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

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

Bot Templates

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

Development

To set up the development environment:

  1. Clone the repository:
git clone https://github.com/kazirocom/typescript-client.git
cd typescript-client
  1. Install dependencies:
npm install
  1. Build the package:
npm run build
  1. Run tests:
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.

1.0.1

9 months ago