# suilend-public/sdk

A TypeScript SDK for interacting with the Suilend program published on npm as [`@suilend/sdk`](https://www.npmjs.com/package/@suilend/sdk).

### Pyth access

Public Hermes requires a Pyth API key, so `initializeSuilend` and `initializeSuilendAll` need yours. Without it, every price read fails with 401. The Suilend API's Pyth routes, `/proxy/latest-prices` and `/proxy/price-update-data`, spend our key and only answer Suilend's own frontends, so a third-party browser page cannot use them.

On a server, pass the key in `pythConnectionConfig`:

```ts
import { initializeSuilend } from "@suilend/sdk";

const data = await initializeSuilend(suiGrpcClient, suilendClient, undefined, undefined, {
  pythConnectionConfig: { accessToken: process.env.PYTH_KEY! },
});
```

In a browser, never ship the key in your bundle. Implement a `PriceFeedSource` that reads from your own backend, which holds the key, and pass it as `pythConnection`.

`/proxy/price` and `/proxy/prices` stay open to every origin, so `getPrices` from `@suilend/sui-core`, which `initializeSuilend` uses by default, keeps working from any site.

---

Got a suggestion, running into issues, or have a question? Join our [#dev-support](https://discord.com/channels/1202984617087598622/1238023733403193385) channel on Discord.
