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

# Market API TypeScript example

> End-to-end TypeScript example: call the Velora Market API to quote 1 ETH → USDC via plain fetch.

A minimal Node script that calls `GET /prices` and prints the quoted `destAmount`. No SDK, just `fetch`.

## File tree

```text theme={null}
my-app/
├─ package.json
├─ tsconfig.json
└─ src/
   └─ quote.ts
```

## Install

<CodeGroup>
  ```bash pnpm theme={null}
  mkdir my-app && cd my-app
  pnpm init
  pnpm add -D typescript tsx @types/node
  pnpm tsc --init
  ```

  ```bash npm theme={null}
  mkdir my-app && cd my-app
  npm init -y
  npm install -D typescript tsx @types/node
  npx tsc --init
  ```

  ```bash yarn theme={null}
  mkdir my-app && cd my-app
  yarn init -y
  yarn add -D typescript tsx @types/node
  yarn tsc --init
  ```
</CodeGroup>

## `src/quote.ts`

```ts theme={null}
const params = new URLSearchParams({
  srcToken:     '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', // ETH
  destToken:    '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', // USDC
  amount:       '1000000000000000000', // 1 ETH
  srcDecimals:  '18',
  destDecimals: '6',
  side:         'SELL',
  network:      '1',
  userAddress:  '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
  partner:      'my-app-name',
  version:      '6.2',
});

const res = await fetch(`https://api.velora.xyz/prices?${params}`);

if (!res.ok) {
  throw new Error(`HTTP ${res.status}: ${await res.text()}`);
}

const { priceRoute } = await res.json();

console.log('destAmount:', priceRoute.destAmount);
console.log('gasCostUSD:', priceRoute.gasCostUSD);
```

## Run it

```bash theme={null}
pnpm tsx src/quote.ts
```

You should see the quoted `destAmount` (USDC, 6 decimals) and `gasCostUSD` printed.

## Next: build the transaction

Feed the `priceRoute` into `POST /transactions/:chainId` to get ready-to-broadcast calldata. See [Market API → How it works](/market/how-it-works).

## Related pages

* [Market API overview](/market/overview) — when to use Market routing.
* [Market API → How it works](/market/how-it-works) — quote → build → broadcast flow.
* [Market API reference](/api-reference/market/overview) — full parameter list.
* [SDK](/sdk/overview) — typed TypeScript wrapper if you'd rather not handle HTTP yourself.
