Skip to main content

Documentation Index

Fetch the complete documentation index at: https://pond.dflow.net/llms.txt

Use this file to discover all available pages before exploring further.

During development, you can use the developer endpoints without an API key. For production use, you’ll need an API key to avoid rate limits.
Priority fees only affect when a trade executes. They do not change routing, slippage checks, or trade semantics (what priority fees do not affect). How DFlow handles priority fees details the two modes.
1

Set up

Imports, env config, and the constants used across every step.
import "dotenv/config";

import { Keypair } from "@solana/web3.js";
import bs58 from "bs58";

const DFLOW_TRADE_API_URL = process.env.DFLOW_TRADE_API_URL ?? "https://dev-quote-api.dflow.net";
const DFLOW_API_KEY = process.env.DFLOW_API_KEY; // optional; not needed for dev endpoints
const DFLOW_SETTLEMENT_MINT = process.env.DFLOW_SETTLEMENT_MINT ?? "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"; // USDC

const SOL_MINT = "So11111111111111111111111111111111111111112";
const amount = 1_000_000; // 0.001 SOL

const keypair = Keypair.fromSecretKey(
  bs58.decode(process.env.SOLANA_PRIVATE_KEY ?? "")
);

const headers: HeadersInit = {};
if (DFLOW_API_KEY) headers["x-api-key"] = DFLOW_API_KEY;
2

Choose your priority fee mode

Use max priority fee for adaptive speed (server selects a fee up to your cap), or exact priority fee when you need predictable costs.
3

Apply priority fees to your request

Set prioritizationFeeLamports on the /order request as either a lamport value or one of auto, medium, high, veryHigh, disabled.
const maxParams = new URLSearchParams();
maxParams.append("inputMint", SOL_MINT);
maxParams.append("outputMint", DFLOW_SETTLEMENT_MINT);
maxParams.append("amount", amount.toString());
maxParams.append("userPublicKey", keypair.publicKey.toBase58());
maxParams.append("slippageBps", "50");

// Adaptive fee chosen by the server.
maxParams.append("prioritizationFeeLamports", "high");
// Or use automatic selection:
// maxParams.append("prioritizationFeeLamports", "auto");

const maxOrderResponse = await fetch(
  `${DFLOW_TRADE_API_URL}/order?${maxParams.toString()}`,
  { headers }
).then((x) => x.json());
const exactParams = new URLSearchParams();
exactParams.append("inputMint", SOL_MINT);
exactParams.append("outputMint", DFLOW_SETTLEMENT_MINT);
exactParams.append("amount", amount.toString());
exactParams.append("userPublicKey", keypair.publicKey.toBase58());
exactParams.append("slippageBps", "50");

// Fixed priority fee in lamports.
exactParams.append("prioritizationFeeLamports", "20000");

const exactOrderResponse = await fetch(
  `${DFLOW_TRADE_API_URL}/order?${exactParams.toString()}`,
  { headers }
).then((x) => x.json());

Priority Fees

How priority fees and the fee budget work, and when to use each mode.

Spot Quickstart

Execute your first spot swap end-to-end.

Add Platform Fees

Monetize trades with builder fees.

Authenticate Requests

Authenticate requests for production rate limits.

API Routes