Book a free call

How to Integrate a Liquidity API into Crypto Exchange Software

A liquidity API feeds your exchange live prices and fills from outside venues. Here are the provider types, steps to integrate, and checks that keep fills honest.

Hertiv engineering teamReviewed by a senior engineer
8 min read
How to Integrate a Liquidity API into Crypto Exchange Software
On this page

Short answer

A liquidity API connects your exchange software to outside markets so your users get live prices and fills even when your own order book is thin. You pick a source such as a swap aggregator, a market maker or a prime broker, connect its market-data feed, request time-bound quotes, execute fills, and reconcile every trade against your ledger.

What is a liquidity API?

A liquidity API is an interface that lets your exchange software pull prices and fills from outside venues. Instead of waiting for your own order book to fill up, your exchange asks another market for a price, takes the fill, and settles it with your user.

There are four common kinds. A swap aggregator API, such as the 0x Swap API or the 1inch Swap API, routes a trade across dozens of decentralised exchanges and returns executable transaction data. A market-maker API gives you firm quotes from a professional trading firm, usually through request-for-quote.

An exchange market-data API streams prices and order books from a large centralised exchange. A prime brokerage API, such as FalconX or CEX.IO Prime, bundles aggregated liquidity with settlement and reporting.

All four solve the same cold-start problem: a new exchange has no depth, so the first trades are expensive or fail. Outside liquidity fills that gap while your own book grows.

API typeExamplesWhat you get
Swap aggregator0x, 1inch, Velora, OdosBest route across DEXs
Market maker RFQWintermute, GSRFirm quotes for large trades
Exchange APIBinance, OKX, CoinbaseLive books and fills
Prime brokerFalconX, CEX.IO PrimeAggregated liquidity plus settlement

The right choice depends on what your exchange is. A decentralised exchange usually starts with an aggregator API, a centralised exchange usually starts with a market maker or a prime broker, and many teams use two sources so one outage does not stop trading.

Which liquidity source fits your exchange?

Pick the source by matching it to your trade size, your settlement model and how much operational work you can take on.

Aggregator APIs are the easiest start for a decentralised exchange. You send a token pair and an amount, and the API returns a quote with the route and the transaction data to execute it. You pay no spread to a counterparty, but the quote is only as good as the on-chain liquidity it can reach.

Market-maker RFQ fits large or illiquid trades. You ask for a price on a specific size and get a firm quote that holds for a few seconds. The maker takes the other side, so the fill is certain if you accept in time. The trade-off is a relationship to manage, with onboarding and credit checks.

Exchange APIs give you the deepest books, but they carry counterparty risk and need a funded account. Prime brokers sit above all of these: one integration and settlement handled for you, at a higher fee.

SourceBest forHow you payMain risk
Aggregator APIDEX swaps, small tradesGas, small routing feeThin on-chain depth
Market maker RFQLarge, illiquid tradesSpread on the quoteQuote expiry, counterparty
Exchange APIDeep books, many pairsMaker-taker feesFunds held at the venue
Prime brokerOne integration, many venuesAll-in spread or feeHigher cost, single provider

Teams that want to compare the sources against supplying depth themselves can start from how to implement a liquidity pool.

What do you need before you start?

You need five things in place before you write the first integration call: an account with the provider, credentials stored safely, a sandbox to test against, settlement accounts, and a clear view of the costs.

Most providers issue an API key and, for trading, a secret used to sign requests. Store both in a secrets manager, never in source code or in a client-side app. Rotate keys on a schedule and keep a separate key per environment, so a leaked test key cannot touch production funds.

Use the provider's sandbox or testnet first. Aggregator APIs usually have a free tier or a test mode; market makers and prime brokers give you a test account during onboarding. Test the full flow there, including failed quotes and rejected orders, before you connect real money.

Settlement is where many integrations stall. Decide in advance where filled trades settle: a hot wallet, a custody account, or the provider's own account. Know the funding and withdrawal times, and make sure your finance team can reconcile provider statements against your own ledger. Finally, check the fee schedule and the rate limits, and confirm that the pairs and chains you need are actually covered.

Before you choose a source, it helps to be clear on why liquidity matters to a crypto exchange in the first place.

How do you integrate a liquidity API in 6 steps?

You integrate a liquidity API by connecting market data first, then quotes, then execution, then reconciliation, testing each layer before you add the next one.

  1. Pick the provider and the endpoints. Choose the source that fits your trade size and settlement model, and note which endpoints you need: market data, quote, order and settlement.
  2. Store credentials safely. Put API keys and signing secrets in a secrets manager with per-environment keys and a rotation plan.
  3. Connect market data. Subscribe to the WebSocket order-book or price feed, and keep a local copy of the book so you can quote users without a round trip.
  4. Request quotes. Call the quote endpoint with pair, side and size, and treat every quote as time-bound: record its expiry and never execute a stale one.
  5. Execute and confirm fills. Send the order, wait for the fill confirmation, and record the executed price, size and fee before you update the user's balance.
  6. Reconcile and log everything. Match every fill against your ledger and the provider's statement, and log each request and response for later audit.

Build the integration as a small service with a clean boundary: your matching engine asks it for a price and a fill, and it hides the provider's protocol. That way you can swap providers, or add a second one, without touching the rest of the exchange. The same separation of concerns applies when you build a hybrid crypto exchange.

How do quotes, fills and settlement work?

A quote is a price for a specific size at a specific moment. It is not a promise that the price will still be there when you accept it.

There are two kinds. An indicative quote is an estimate from the current order book: it can move before you act. A firm quote, the kind an RFQ returns, is a price the maker will honour for a few seconds. For large trades, firm quotes are the only safe basis for showing a price to a user.

When you accept, the fill may be partial. A 2 BTC buy might fill 1.2 BTC at one price and 0.8 BTC at the next level up, and your code must handle that split: update the user's balance with what actually filled, and decide whether to chase the remainder or cancel it. Record the average executed price, not the quoted price, in the user's trade history.

Settlement is the movement of assets after the fill. On a centralised venue it is usually an internal ledger update plus a periodic withdrawal to your wallet. On a decentralised route it is an on-chain transaction that settles when the block confirms. Either way, do not credit a user until the settlement is confirmed, and keep the provider's trade id on every record so a dispute can be traced.

How do you keep the integration reliable?

A liquidity integration fails in boring ways: a slow provider, a stale quote, a dropped WebSocket, a key that expired overnight. Reliability comes from expecting each of these and handling it in code.

Set a timeout on every quote and order call, and retry with backoff rather than hammering a struggling provider. A quote request that takes more than a second is usually worse than no quote at all, because the price it returns is already old.

Put a circuit breaker around each provider. If errors or timeouts pass a threshold, stop routing to it for a few minutes and fall back to your second source. Log the switch so your team can see it, and alert a human if the fallback is also failing.

Watch quote freshness as a metric. If the newest quote in your cache is older than a few seconds, stop showing prices for that pair until the feed recovers. Rotate API keys on a schedule, keep a spare key ready, and run a daily health check that places a tiny test quote through each provider and confirms the round trip works.

For a fuller picture of how the four sources compare inside one exchange, see how hybrid crypto exchanges solve liquidity.

Example (hypothetical): adding BTC/USDT depth to a new exchange

Example (hypothetical): a new exchange lists BTC/USDT but its own book is thin, so it routes large market buys through a liquidity API. A user places a market buy for 2 BTC.

The API returns a quote that splits the fill across two levels: 1.2 BTC at $97,000 and 0.8 BTC at $97,050. The exchange accepts it, and the fills come back exactly as quoted.

The maths is straightforward. The first slice costs 1.2 times $97,000, which is $116,400. The second slice costs 0.8 times $97,050, which is $77,640. Together the user pays $194,040 for 2 BTC, an average price of $97,020.

The provider charges a 0.1% fee on the filled value, which is $194.04. The user's total cost is $194,234.04. The exchange records the two fills, the average price and the fee, and only then credits 2 BTC to the user's balance and updates its ledger.

What are the common mistakes?

The most common liquidity API mistakes are trusting a quote too far, having no fallback, and skipping reconciliation.

  • Treating an indicative quote as firm. Showing a user a price from a stale book guarantees either a failed fill or a loss. Use firm quotes for large trades and refresh indicative ones constantly.
  • No timeout on quotes. A quote that took three seconds to arrive is already history. Expire quotes fast and fetch a new one.
  • One provider, no fallback. When your only source goes down, trading stops. Keep a second source wired in, even if it only covers your top pairs.
  • Keys in code. API keys and signing secrets in source control or client code are a breach waiting to happen. Use a secrets manager.
  • Ignoring partial fills. If you credit the full order when only part filled, your ledger is wrong from the first trade. Record what actually filled.
  • Skipping reconciliation. Without a daily match between your ledger and the provider's statement, small errors grow into large ones.

Key takeaways

  • A liquidity API fills the cold-start gap: outside depth while your own book grows
  • Aggregator APIs suit DEX swaps, RFQ suits large trades, prime brokers bundle settlement
  • Treat every quote as time-bound and never execute a stale one
  • Record what actually filled, including partial fills and the average price
  • Keep a second provider as a fallback and reconcile your ledger daily

Frequently asked questions

What is a liquidity API?

A liquidity API is an interface that lets exchange software fetch prices and execute trades on outside venues. Your exchange sends a pair and a size, and the provider returns a quote and, when accepted, a fill. It is how a new exchange offers deep markets before its own order book has depth.

How is an aggregator API different from a market maker?

An aggregator routes your trade across many decentralised exchanges and returns the best on-chain route, while a market maker gives you a firm quote from its own book. Aggregators suit smaller DEX trades; market makers suit large trades where you want a guaranteed price for a few seconds.

What is RFQ in crypto liquidity?

RFQ, or request-for-quote, is a way to ask a market maker for a firm price on a specific trade size. The quote is binding for a short window, usually a few seconds. It is the standard route for large or illiquid trades where an open order book would move the price.

Do I need a licence to use a liquidity API?

Using an API does not remove your own regulatory duties. Whether you need a licence depends on where you operate and what you offer, not on which provider you use. Check the rules in each jurisdiction you serve before you launch, and keep records of every trade.

What does a liquidity API cost?

Costs vary by source. Aggregator APIs usually charge little or nothing beyond gas and a small routing fee, market makers earn the spread on your trades, and prime brokers charge an all-in fee. Ask for the full fee schedule, including withdrawal and settlement fees, before you sign up.

How do I test a liquidity integration safely?

Use the provider's sandbox or testnet and a separate set of test credentials. Run the full loop: quote, execute, confirm the fill and reconcile the ledger, including failed quotes and partial fills. Only connect real funds once the test loop works end to end.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: blockchain systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Adding outside liquidity to your exchange? Talk to Hertiv.

A senior engineer replies within one business day. Or see our Crypto Exchange service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to contact@hertiv.com.

Prefer email? Write to contact@hertiv.com
Estimate costBook a call