Use when an agent needs a swap quote and price impact before trading
1gateway.dev/v1/onchain/swap/quote
Use when an agent needs a swap quote and price impact before trading. Input: chain (base, ethereum, arbitrum), from, to (ticker like USDC, ETH or 0x address), amounts (1-5 sizes in from-token units). Output: JSON per size best venue (Uniswap v3 fee tier, Uniswap v2, Aerodrome), amount out, effective price, price impact %, all venue quotes, spot price. Quote only: no calldata, nothing executed. Exa
GET
https://1gateway.dev/v1/onchain/swap/quoteUptime100% of 4 checks in 30 days
30 days agoToday
Try it
Pays from your browser wallet in USDC on Base or USDG on Robinhood Chain, whichever the endpoint takes. The provider is paid directly; failed calls aren't refunded by Fourohtwo.
The response shows up here.
Call it from an agent
// npm install fourohtwo
import { createPayer } from "fourohtwo";
// One agent key pays USDC on Base or USDG on Robinhood Chain, inside your spending rules.
const pay = createPayer({ privateKey: process.env.AGENT_KEY, maxPerCallUsd: "0.05" });
const res = await pay("https://1gateway.dev/v1/onchain/swap/quote?amounts=1000%2C100000&chain=base&from=USDC&to=ETH");
console.log(await res.json());Example input
{
"amounts": "1000,100000",
"chain": "base",
"from": "USDC",
"to": "ETH"
}