> ## Documentation Index
> Fetch the complete documentation index at: https://docs.oneswap.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# Launchpad SDK

> Read launchpad coins, trades, holder counts, and quotes with a read-only Launchpad API key.

The Launchpad SDK gives you read-only access to the OneSwap Launchpad: coins, prices, trades,
holder counts, and indicative quotes. Use it for dashboards, market monitors,
analytics, and listings. It cannot trade. To trade launchpad coins on your own wallet, use the
[Trader SDK](https://docs.oneswap.cc/guides/trader-sdk.md#trade-launchpad-coins). To call the API over HTTP from
another language, see the [Launchpad API](https://docs.oneswap.cc/guides/launchpad-api.md).

## Install

```bash theme={null}
npm install @oneswap/launchpad-sdk
```

## Get a Launchpad API key

Sign in to OneSwap and open **Developer**. Under **Launchpad API keys**, enter an optional
label and click **Generate key**.

| Network | Create keys at |
| - | - |
| Mainnet | [swap.oneswap.cc](https://swap.oneswap.cc) |
| Devnet | [devnet.oneswap.cc](https://devnet.oneswap.cc) |

A key looks like `lpk_live_` followed by 48 hex characters.

* The key is read-only. It is not linked to a wallet and cannot move funds.
* You can hold up to five active keys. Revoke a key from the same page.
* Each key has its own per-minute request limit. Contact OneSwap if you need a higher one.

> [!WARNING]
>
> The key is shown once, at creation. OneSwap stores only a hash of it. If you lose a key,
> generate a new one and revoke the old one. Keep keys on a server, not in browser code.

## Create the client

```ts theme={null}
import { LaunchpadSDK } from '@oneswap/launchpad-sdk'

const lp = new LaunchpadSDK({
  apiKey: process.env.ONESWAP_LAUNCHPAD_KEY!,
  environment: 'mainnet', // or 'devnet'
})
```

## List coins

```ts theme={null}
const { coins, nextCursor } = await lp.coins({ sort: 'volume', lane: 'new', limit: 20 })

for await (const coin of lp.allCoins({ sort: 'mcap' })) {
  console.log(coin.symbol, coin.price, coin.marketCap, coin.graduationPercent)
}
```

* `sort` is `recent` (default), `volume`, or `mcap`.
* `lane` is `new`, `stretch`, or `graduated`.
* Prices, market caps, and volumes are in CC.
* Pass `nextCursor` back as `cursor` to page manually, or use `allCoins` to page for you.

## Read one coin

```ts theme={null}
const coin = await lp.coin(coinId)
console.log(coin.curve, coin.holderCount, coin.recentTrades.length)
```

A coin includes its bonding-curve state, recent trades, and its holder count. After
graduation, `liquidityMigrated` turns `true` once the coin trades on its pool.

### Links and image

`imageUrl`, `websiteUrl`, `xUrl`, and `telegramUrl` show the coin's current image and links.
The creator can change them at any time after launch, from **My launches** → **Edit links &
image**. A link the creator removes comes back as an empty string.

> [!TIP]
>
> Don't cache a coin's image or links forever. Read them again from `coin` or `coins` to pick up
> the creator's latest edit.

## Trades and holder count

```ts theme={null}
const { trades } = await lp.trades(coinId, { limit: 50 })
for await (const trade of lp.allTrades(coinId)) {
  // newest first
}

const latest = await lp.recentTrades() // across all public coins

const { holderCount, holderData } = await lp.holders(coinId)
if (holderData.status === 'complete') {
  console.log(holderCount)
}
```

You get how many wallets hold a coin, not who holds it: no addresses, usernames, or balances.
After graduation, holder data can be `unavailable` because pool holdings are not indexed.

## Quotes

```ts theme={null}
const buy = await lp.quote(coinId, { side: 'buy', amount: 25 }) // spend 25 CC
const exact = await lp.quote(coinId, { side: 'buy', tokensOut: '1000000' }) // receive exact tokens
const sell = await lp.quote(coinId, { side: 'sell', amount: 500000 }) // sell tokens
```

Quotes are indicative. They are not tied to a wallet and do not include the network fee. A
graduated coin whose liquidity is still moving to its pool returns `ConflictError` until the
move completes.

## Errors and rate limits

Every failure is a subclass of `LaunchpadError` with `status`, `code`, and `data`:

| Error | When |
| - | - |
| `AuthError` | The key is missing or revoked. |
| `ForbiddenError` | The key's account cannot read the launchpad yet. |
| `ValidationError` | An argument is invalid. |
| `NotFoundError` | The coin does not exist or is withheld from public reads. |
| `ConflictError` | The coin's liquidity is still migrating. |
| `RateLimitError` | The key used up its per-minute limit. |
| `ServerError`, `NetworkError`, `TimeoutError` | The request failed upstream or in transit. |

When a key goes over its limit, the SDK waits for the server's retry delay and tries again,
twice by default. Set `maxRateLimitRetries: 0` to handle `RateLimitError` and its
`retryAfterSeconds` yourself.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.