Short answer: The Uniswap API (the Trading API at https://trade-api.gateway.uniswap.org/v1) is a hosted service that finds a route, returns a quote and builds unsigned swap calldata; your wallet signs and your RPC provider broadcasts. Every request needs an x-api-key header; the FAQ, read on 26 November 2026, says the API is free and allows 6 requests per second per key by default. The flow is /check_approval, /quote, then /swap or /order depending on the routing field.
Sources are developers.uniswap.org and the OpenAPI file at /v1/api.json, read on 26 November 2026. No API key, wallet or private key was used, so quote and swap responses come from the documentation; the error format and a keyless pool read were tested live, and contradictions are flagged.
This is a technical guide, not a recommendation of Uniswap, any token, pool or strategy. Smart-contract swaps and the leveraged margin endpoints carry a high risk of loss. Article 99/A of Capital Markets Law No. 6362 treats activity by foreign crypto-asset platforms directed at Turkish residents as unauthorized. Rules depend on your jurisdiction and Uniswap Labs' API Terms of Use, which returned HTTP 403 to two read attempts on 26 November 2026.
What the Uniswap Trading API does and what your app still does
The hosted API quotes and builds transactions; signing, nonces, broadcasting and paying gas stay with your application.
| Uniswap API | Your application |
|---|---|
| Route finding across Uniswap v2, v3, v4 pools and UniswapX | Nonce management for the user's wallet |
| Unsigned transaction calldata | Signing (wallet) and broadcasting (your RPC provider) |
| Allowance checks, simulation, gas estimate | Paying gas, handling reverts |
The trading overview also lists the TypeScript SDK and direct contract calls. Keep the key in your backend, never in front-end code, as explained in API key security for trading bots.
Uniswap API key: how to get one and how requests are authenticated
You create a key in the Uniswap Developer Platform dashboard and send it in the x-api-key header with Content-Type and Accept both set to exactly application/json.
The pages disagree on access: the integration guide describes self-service keys, while one FAQ answer still says to "reach out to request an API key". A 401 can also come from extra values in the accept or content-type header.
| Item | What the docs say |
|---|---|
| Price | "The API is free to use"; integrators may add their own fee with integratorFees (up to 4 entries, at most 500 bips in total) |
| Rate limit | 6 requests per second per key by default; increases through the Help form |
| Testing | No sandbox; Unichain Sepolia (1301), Base Sepolia (84532) and Ethereum Sepolia (11155111) via production endpoints |
| Tokens | Pairs on Uniswap Labs' unsupported-token list get no quote |
A request sent without a key on 26 November 2026 returned HTTP 401 with the body {"errorCode":"Unauthorized","detail":"Unauthenticated api key or session","requestId":"..."}. Its CORS header exposed x-ratelimit-limit and x-ratelimit-remaining; whether successful responses carry them could not be checked. For 429 handling, see exponential backoff with jitter in Python and the API rate limit calculator.
Uniswap quote API: check_approval, quote, then swap or order
Call /check_approval, then /quote, then read the top-level routing field to decide whether the next call is /swap, /order or /plan.
POST /quote requires type (EXACT_INPUT or EXACT_OUTPUT), amount in the token's smallest unit, tokenIn, tokenOut, both chain IDs and swapper, and exactly one of slippageTolerance or autoSlippage. The native coin uses the zero address.
routing | Meaning | Next call |
|---|---|---|
CLASSIC | AMM swap through Uniswap pools; you pay gas | POST /swap |
WRAP, UNWRAP | ETH to WETH and back | POST /swap |
BRIDGE | Cross-chain bridge | POST /swap |
DUTCH_V2, DUTCH_V3, PRIORITY | UniswapX order filled by a third party (gasless for the user) | POST /order |
CHAINED | Cross-chain or multi-step trade | /plan endpoints |
The OpenAPI enum also lists DUTCH_LIMIT and LIMIT_ORDER, which the guide's table omits; limit orders have their own /limit_order_quote endpoint, and the client below refuses values it does not map. Two contradictions: the routing table lists PRIORITY, but the FAQ says priority quotes are "not currently returned by the API"; and one FAQ answer says UniswapX never takes native ETH input, while the integration guide says the x-erc20eth-enabled: true header enables it. When no permit is needed, /quote may already include swapTransaction.
The guide says to refuse a transaction whose data is empty or 0x, never to edit data, and to re-quote after 30 seconds. The /lp/ and leveraged /margin/ endpoints are not covered here.
Permit2 in the Uniswap API: what to sign and send
When /quote returns a non-null permitData, the user signs it as EIP-712 typed data and you send quote, signature and permitData together to /swap.
- Both or neither. Sending a signature without
permitData, or the reverse, fails validation. WhenpermitDatais null, omit both. - No reuse. A permit signature belongs to one quote; a new quote needs a new signature.
- Amount scope.
permitAmountisFULL(maximum allowance, which stays standing) orEXACT(this swap only). - Missing fields. Some signing libraries need fields, such as
EIP712Domain, that the API does not return. - Router version. Without the
x-universal-router-versionheader the API defaults to Universal Router 2.1.2 where deployed (zkSync runs 2.0 only). A 21 September 2026 changelog says pinning 2.0 or 2.1.1 errors from 21 October 2026, yet the chains page and OpenAPI file still list both on 26 November 2026. Pin the version you tested.
Uniswap API slippage and gas fields as mechanics
slippageTolerance is a percentage from 0 to 100 with up to two decimals that sets the minimum output (exact input) or maximum input (exact output); autoSlippage: "DEFAULT" lets the API compute it for Uniswap pools only.
The OpenAPI file defines the minimum received as expectedOut × (1 − slippageTolerance). Suggested ranges in the docs are not repeated here, because the right value depends on pair, size and signing delay. For UniswapX routes, the tolerance does not cap the order's spread. See slippage in crypto trading for the general mechanics.
Hypothetical example. An exact-input quote expects 250,000,000 raw units of a 6-decimal token (250.000000). With slippageTolerance 0.5 the minimum received is 250,000,000 × 0.995 = 248,750,000 (248.75); with 2 it is 245,000,000 (245.00). The slippage calculator does the same arithmetic.
For gas, urgency accepts NORMAL, FAST or URGENT, or an object with fee and gas-limit caps. The FAQ says that when gas is 20% or more of trade value, the API returns only Uniswap pool quotes or fails, never a gasless UniswapX quote.
Uniswap API errors: status codes and the body you actually get
Parse errorCode and detail: that is what the live API returned and what the OpenAPI file defines, while the integration guide's sample interface shows error, message and details.
A 404 from /quote means no quote was found; only errorCode UpstreamTimeoutError is worth repeating unchanged, while NoRouteFoundError or QuoteAmountTooLowError need a changed request.
import os
import requests
BASE = "https://trade-api.gateway.uniswap.org/v1"
NEXT = {"CLASSIC": "/swap", "WRAP": "/swap", "UNWRAP": "/swap", "BRIDGE": "/swap",
"DUTCH_V2": "/order", "DUTCH_V3": "/order", "PRIORITY": "/order", "CHAINED": "/plan"}
class ApiError(Exception):
pass
def error_fields(resp):
try:
body = resp.json()
except ValueError:
return "NonJsonBody", resp.text[:120]
if not isinstance(body, dict):
return "UnexpectedBody", str(body)[:120]
# live API: errorCode/detail; one doc page shows error/message
return body.get("errorCode") or body.get("error") or "Unknown", body.get("detail") or body.get("message") or ""
def quote(req, key=None):
key = (key or os.environ.get("UNISWAP_API_KEY", "")).strip()
if not key:
raise ValueError("no API key set; nothing was sent")
headers = {"x-api-key": key, "Content-Type": "application/json", "Accept": "application/json"}
try:
r = requests.post(BASE + "/quote", json=req, headers=headers, timeout=20)
except requests.RequestException as e:
raise ConnectionError(f"network error before any API answer: {e}") from e
if r.status_code == 200:
try:
q = r.json()
except ValueError:
q = None
routing = q.get("routing") if isinstance(q, dict) else None
if isinstance(routing, str) and routing in NEXT:
return q, NEXT[routing]
raise ApiError(f"HTTP 200 with unknown routing {repr(routing)}; not guessing")
code, detail = error_fields(r)
raise ApiError(f"HTTP {r.status_code} {code}: {detail}")
if __name__ == "__main__":
req = {"type": "EXACT_INPUT", "amount": "1000000", # 1 USDC
"tokenIn": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"tokenOut": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"tokenInChainId": 1, "tokenOutChainId": 1,
"swapper": "0x000000000000000000000000000000000000dEaD", "autoSlippage": "DEFAULT"}
for key in ("", "not-a-real-key"):
try:
print(quote(req, key=key))
except (ValueError, ApiError, ConnectionError) as e:
print(type(e).__name__, "-", e)
Output on 26 November 2026 (no key was available, so only the failure paths ran):
ValueError - no API key set; nothing was sent
ApiError - HTTP 401 Unauthorized: Unauthenticated api key or session
Mocked tests: an unreachable host raises ConnectionError; HTML, list or error/message bodies, including a non-JSON 200, raise ApiError, never KeyError; an unknown routing such as LIMIT_ORDER is refused.
Reading Uniswap pool prices without an API key
A pool's current price can be read straight from the contracts with a JSON-RPC eth_call, which needs no Uniswap key and signs nothing.
The script asks the UniswapV3Factory (address from Uniswap's deployments page) for a pool, reads slot0() and converts sqrtPriceX96 with Decimal, so large integers never become floats. The pair is an example, not a recommendation.
from decimal import Decimal, getcontext
import requests
getcontext().prec = 60
RPC = "https://ethereum-rpc.publicnode.com" # or your own node
FACTORY = "0x1F98431c8aD98523631AE4a59f267346ea31F984" # UniswapV3Factory, mainnet
GET_POOL, SLOT0 = "0x1698ee82", "0x3850c7bd" # function selectors
def eth_call(to, data):
try:
r = requests.post(RPC, timeout=15, json={"jsonrpc": "2.0", "id": 1, "method": "eth_call",
"params": [{"to": to, "data": data}, "latest"]})
except requests.RequestException as e:
raise RuntimeError(f"network error, nothing was read: {e}") from e
try:
body = r.json() if r.status_code == 200 else {"error": f"HTTP {r.status_code}"}
except ValueError:
body = {"error": "reply was not JSON"}
if not isinstance(body, dict):
body = {"error": "unexpected reply shape"}
if "error" in body: # JSON-RPC errors arrive with HTTP 200
err = body["error"]
raise RuntimeError(f"RPC error: {err.get('message') if isinstance(err, dict) else err}")
if not isinstance(body.get("result"), str) or body["result"] in ("", "0x"):
raise RuntimeError(f"no usable result from {to}: not a contract or wrong function")
return body["result"]
def get_pool(a, b, fee):
data = GET_POOL + format(int(a, 16), "064x") + format(int(b, 16), "064x") + format(fee, "064x")
pool = "0x" + eth_call(FACTORY, data)[-40:]
if int(pool, 16) == 0:
raise LookupError(f"no pool for this pair at fee {fee}")
return pool
def pool_price(pool, dec0, dec1):
res = eth_call(pool, SLOT0)
sqrt_p = int(res[2:66], 16) if len(res) >= 66 else 0
if sqrt_p == 0:
raise LookupError(f"pool {pool} has no price yet (not initialised)")
raw = Decimal(sqrt_p) ** 2 / Decimal(2) ** 192 # token1 per token0, raw units
return raw * Decimal(10) ** (dec0 - dec1)
if __name__ == "__main__":
USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" # token0, 6 decimals
WETH = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" # token1, 18 decimals
pool = get_pool(USDC, WETH, 500)
price = pool_price(pool, 6, 18)
print("pool", pool, "| USDC per WETH", f"{1 / price:.2f}")
try:
get_pool(USDC, WETH, 1234)
except LookupError as e:
print("expected:", e)
Output on 26 November 2026 (the price changes every block; this is a test reading, not market data):
pool 0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640 | USDC per WETH 1694.41
expected: no pool for this pair at fee 1234
An address with no code, an uninitialised pool, malformed calldata (execution reverted, with HTTP 200), a non-JSON or list reply, a string error, HTTP 503 and an unreachable host each raised a clear error in tests. A slot0 price ignores fees and price impact; QuoterV2 or the API gives a size-aware number.
Uniswap subgraph versus the Uniswap API
Subgraphs serve history and analytics through GraphQL on The Graph; the Trading API serves executable quotes.
Two cautions from 26 November 2026. Uniswap's "Using Subgraphs" guide still points to api.thegraph.com/subgraphs/name/uniswap/uniswap-v2, which now redirects to an error page. A keyless call to The Graph's gateway for the v3 subgraph returned HTTP 200 with auth error: missing authorization header, so check the errors array, not only the status; a key from The Graph is needed. Indexed data can lag the chain, so do not base a transaction on it. For broader options, see what a crypto API is.
Uniswap is named here to describe its official documentation; naming it does not mean Fincode integrates it or has built on it. Fincode's exchange API integration service is linked only as a general pointer.
Related guide: Birdeye API in Python · The Graph subgraph API.
Frequently asked questions
Is the Uniswap API free?
The Uniswap API FAQ, read on 26 November 2026, says the API is free to use. Gas is still paid by whoever broadcasts, and integrators may add a fee with integratorFees.
What is the Uniswap API rate limit?
By default each API key is limited to 6 requests per second, according to the FAQ read on 26 November 2026. Higher limits are requested through Uniswap's Help form, and exceeding the limit returns HTTP 429.
Does the Uniswap API have a sandbox or testnet?
There is no sandbox. The FAQ lists Unichain Sepolia, Base Sepolia and Ethereum Sepolia as testnets reachable through the production endpoints, as read on 26 November 2026.
Does the Uniswap API need my private key?
No. It returns unsigned transactions or typed data for the user's wallet to sign. Never send a private key or seed phrase to any API.
Sources
- Uniswap developers: Swapping API Integration Guide, read 26 November 2026 (opens in a new tab)
- Uniswap developers: Uniswap API FAQs, read 26 November 2026 (opens in a new tab)
- Uniswap Trading API OpenAPI specification (api.json), read 26 November 2026 (opens in a new tab)
- Uniswap developers: Supported Chains & Tokens, read 26 November 2026 (opens in a new tab)
- Uniswap developers: Swapping via the Uniswap API, read 26 November 2026 (opens in a new tab)
- Uniswap developers: Trading Overview, read 26 November 2026 (opens in a new tab)
- Uniswap developers: Uniswap v3 Ethereum deployments, read 26 November 2026 (opens in a new tab)
- Uniswap developers: Using Subgraphs, read 26 November 2026 (opens in a new tab)
- Uniswap developers: v3 subgraph query examples, read 26 November 2026 (opens in a new tab)
- Uniswap developers: Troubleshooting common errors, read 26 November 2026 (opens in a new tab)
This guide is general information about software and markets, not investment, legal or tax advice. Automated trading can lose money, past or backtested performance does not guarantee future results, and the rules that apply depend on your jurisdiction and your exchange's terms. Sources, checks and corrections: see the editorial policy.