> For the complete documentation index, see [llms.txt](https://docs.zofinance.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zofinance.io/building-on-zo/zo-sdk/getting-started.md).

# Getting Started

1\. Create an API or DataAPI instance

Use the **SDK** factory (exported as `SDK` from `zo-sdk`) to create LP-specific instances. You need a Sui client, network, API endpoint, and connection URL.

```typescript
import { SDK, LPToken, Network } from '@zofai/zo-sdk'
import { SuiClient } from '@mysten/sui/client'

const provider = new SuiClient({ url: 'https://fullnode.mainnet.sui.io' })
const network = Network.MAINNET
const apiEndpoint = 'https://api.zofinance.io'
const connectionURL = 'https://hermes.pyth.network'

// Create API instances (transactions + data)
const zlpAPI = SDK.createZLPAPI(network, provider, apiEndpoint, connectionURL)
const slpAPI = SDK.createSLPAPI(network, provider, apiEndpoint, connectionURL)
const usdzAPI = SDK.createUSDZAPI(network, provider, apiEndpoint, connectionURL)

// Or create by LP token enum
const api = SDK.createAPI(LPToken.ZLP, network, provider, apiEndpoint, connectionURL)

// Create DataAPI instances (read-only; no transaction methods)
const zlpDataAPI = SDK.createZLPDataAPI(network, provider, apiEndpoint, connectionURL)
const slpDataAPI = SDK.createSLPDataAPI(network, provider, apiEndpoint, connectionURL)
const usdzDataAPI = SDK.createUSDZDataAPI(network, provider, apiEndpoint, connectionURL)

// Or create DataAPI by LP token
const dataAPI = SDK.createDataAPI(LPToken.SLP, network, provider, apiEndpoint, connectionURL)
```

### 2. API vs DataAPI

| Use case                           | Class                                          | Use                                                                                                                |
| ---------------------------------- | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| **Build transactions + read data** | **API** (`ZLPAPI`, `SLPAPI`, etc.)             | Deposit, withdraw, open/close positions, stake, and also call data methods (market info, vaults, positions, etc.). |
| **Read-only**                      | **DataAPI** (`ZLPDataAPI`, `SLPDataAPI`, etc.) | Only query chain/API state (market valuation, vault info, positions, orders, history). No transaction building.    |

**API** instances expose both transaction methods and data methods. Data methods (e.g. `getMarketInfo`, `valuateMarket`, `getVaultInfo`) are implemented by delegating to the internal `dataAPI`, so you can call them directly on the API or via `api.dataAPI`:

```typescript
const zlpAPI = SDK.createZLPAPI(network, provider, apiEndpoint, connectionURL)

// Data methods are available directly on the API (same result either way)
const marketData = await zlpAPI.valuateMarket()
const marketDataAlt = await zlpAPI.dataAPI.valuateMarket()

// Transaction methods exist only on the API
const depositTx = await zlpAPI.deposit('usdc', ['coinId'], 1000000)
```

**DataAPI** instances are for read-only usage when you don't need to build transactions:

```typescript
const zlpDataAPI = SDK.createZLPDataAPI(network, provider, apiEndpoint, connectionURL)
const marketData = await zlpDataAPI.valuateMarket()
const vaultInfo = await zlpDataAPI.getVaultInfo('usdc')
// zlpDataAPI.deposit(...) does not exist
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.zofinance.io/building-on-zo/zo-sdk/getting-started.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.
