# Typescript

### About

DeltaDeFi's Typescript SDK provides utility functions to interact with the API service and sign transactions with provided keys.

### Installation

The SDK is hosted on npmjs.com, so you can directly import it using your favorite package manager.

```
npm i @deltadefi-protocol/sdk
```

```
yarn add @deltadefi-protocol/sdk
```

### Getting Started

Placing and canceling orders are as simple as below.

```typescript
import { ApiClient } from "@deltadefi-protocol/sdk";

export const getApiClient = async (): Promise<ApiClient> => {
  const network = process.env.NETWORK;
  const apiKey = process.env.API_KEY;
  const operationKeyEncryptionPassword =
    process.env.OPERATION_KEY_ENCRYPTION_PASSWORD!;

  const apiClient = new ApiClient({
    network: network as "preprod" | "mainnet",
    apiKey: apiKey,
  });

  await apiClient.loadOperationKey(operationKeyEncryptionPassword);
  return apiClient;
};
```

### Posting Order

```typescript
// Posting order instantly without fee
export const orders = async () => {
  const apiClient = await getApiClient();

  const orderRequest: PostOrderRequest = {
    symbol: "ADAUSDM",
    side: "sell",
    type: "limit",
    quantity: 100,
    price: 16,
  };

  const res = await apiClient.postOrder(orderRequest);
  console.log("Post Order Response:", res);
};

```

### Cancel Order

```typescript
// Canceling order instantly without fee
const cancelRes = await apiClient.cancelOrder(res.order.order_id);
console.log("Cancel Order Response:", cancelRes);
```

### Detailed SDK demo

<https://github.com/deltadefi-protocol/sdks-demo/tree/main/typescript>


---

# 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.deltadefi.io/start-trading/developers/sdks/typescript.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.
