Getting Started
The 0x suite of APIs is the simplest way to enable faster trading, better prices, and superior UX in your app. To get started, you will need to set up an account to access the 0x Dashboard in order to generate API keys for new projects, monitor and manage integrations, and get access to new APIs and tap into more developer resources.
Follow these steps to get started, in less than 5 minutes!
1. Create a 0x Account
To create an account on the 0x Dashboard, click Sign Up, enter your name, email address and password, and click Continue
2. Create a Team
Once verified, you’ll be prompted to create a team on 0x. Decide on a team name and select the type of project you are building. You can share this account with your teammates.
3. Tour the Dashboard
3.1 Test API Key
Once you’ve created a team, you’ll be taken to the 0x Dashboard where you can create and manage live API keys, find build resources, and raise support requests.
To find a list of all networks supported by 0x, check out the 0x Cheat Sheet.
Your dashboard comes with a Test API key you can use to make sample requests. Give it a try by plugging it into the curl request and running that from your CLI to see a live Swap API quote request:
// Replace the API key in the header with your sample key
curl –location –request GET ‘https://api.0x.org/swap/v1/quote?buyToken=DAI&sellToken=ETH&sellAmount=100000&excludedSources=Kyber’ –header ‘0x-api-key: [api-key]’
3.2 Create an App
Click Create an app to get a live API key that has access to multiple 0x products.
From the pop-up, enter your app’s name and which 0x products (Swap API, Orderbook API) should be enabled for this API key, then click Continue.
Note: You will still be able to update the 0x products this key can unlock even after the app has been created.
3.3 Add 0x Explorer Tag
In the next screen, you can add a unique tag that can be used to identify transaction data from your app on 0x Explorer. You may use the same tag for all your apps, or create a separate one for each.
0x Explorer provides data about ERC-20 transactions routed through 0x API. It’s a reliable and transparent tool to help developers and users verify transactions and analyze on-chain activity in an easy and low-friction way.
Learn more about 0x Explorer Tags.
You can skip for now and add a tag later.
3.4 Reveal Your API Key
On the final screen, copy your API key! This key is unique and tied to your app. Do not share it. You can also create additional API keys for the app if you need them.
Your API keys will allow you to authenticate requests on 0x. Remembmer to specify the key in your requests vai the 0x-api-key header parameter:
This key will allow you to authenticate requests on 0x. Remember to specify the key in your requests via the 0x-api-key header parameter:
// Replace the API key in the header with your sample key
curl –location –request GET ‘https://api.0x.org/swap/v1/quote?buyToken=DAI&sellToken=ETH&sellAmount=100000&excludedSources=Kyber’ –header ‘0x-api-key: [api-key]’
4. Manage Your App
From the main dashboard screen, you can see all the apps you have created:
Click on an App to open up details about it.
For each App, you can see the following:
- See which 0x products are enabled for your API key – Swap API and/or Orderbook API.
- From API Key, see all the API keys associated with this app and create or delete keys. From Settings, change the 0x products enabled for this app. Set your 0x Explorer Tag. Change the App Name.
- If you have set up an 0x Explorer Tag, you can view your on-chain data and transactions related to this app.
- View build resources.
5. Manage Your Account
You can find additional settings to manage your account from Your Account Avatar in the top-right corner.
- Settings – You can see your full name, team name, and account email, as well as change your password.
- Contact Support – Have a question? Reach out to our dev support team.
- Docs – Jump into our developer docs and start building
- Help – Need help? Check out our commonly asked questions and help center.
- 0x Explorer – If you have a 0x Explorer tag setup, easily analyze your app’s on-chain activity and transactions. Learn more about the 0x Explorer Tag.
6. Have a Question?
If you are logged-in to the 0x Dashboard, you have a direct line to our team via the Intercom Messenger for Developer Support in the bottom right of the dashboard.
7. Start Building
Now that you have a live API key, dive into our building resources and start building!
Introduction to 0x
TIP
Prefer to watch a video instead? Jump to 0x Concept Videos.
What is 0x?
0x is developers’ one-stop shop to build financial products on crypto rails. 0x empowers hundreds of developers with essential web3 tools to enable faster trading, better prices and superior UX. Our suite of APIs has processed over 52 million transactions and $125B in volume from more than 6 million users trading on apps like Coinbase Wallet, Robinhood Wallet, Metamask, Zerion, Zapper, and more.
TIP
5ELI5 0x (Explain 0x like I’m 5 Years Old)
0x is like a big playground where people can trade different things like toys, candy, and stickers. But instead of toys and candy, they trade digital things like cryptocurrencies. There are two types of people in this playground: the ones who bring things to trade (we call them Makers) and the ones who want to trade for those things (we call them Takers). 0x helps these people find each other and make trades in a safe and fair way. It’s like having a grown-up watching over the playground to make sure everyone is playing nicely.
The 0x Ecosystem
40x Tech Stack
0x’s professional-grade APIs are built on the 0x Protocol, a set of secure, audited smart contracts. Applications building on these tools are part of the 0x Ecosystem.
The diagram below shows an overview of the 0x Ecosystem, which includes applications who supply liquidity (Makers), applications who demand liquidity (Takers).
3Makers and Takers
Within the 0x Ecosystem, there are two sides – Makers and Takers:
Supply (aka Makers)
This is the entity who creates 0x orders and provides liquidity into the system for the Demand side (Takers) to consume. 0x aggregates liquidity from multiple sources including:
- On-chain liquidity – DEXs, AMMs (e.g. Uniswap, Curve, Bancor)
- Off-chain liquidity – Professional Market Makers, 0x’s Open Orderbook network
- Relevant Docs:
- Market Makers – Professional Market Making With Limit Orders
- Orderbook API – Sharing Limit Orders
- Limit Orders (Advanced Traders)() – Filling and Managing Limit Orders
Demand (aka Takers)
This is the entity who wants the Maker’s asset. The Takers agree to trade their asset for the Maker’s asset; in other words, they consume the 0x liquidity. Examples include projects such as MetaMask, Coinbase, and dydx.
- Relevant Docs:
- Swap API – The most efficient liquidity aggregator for ERC20 tokens through a single API.
How does 0x work?
Let’s look into how a 0x order is executed.
- A Maker creates a 0x order which is a json object that adheres to a standard order message format (see list of all 0x order types here). It indicates what kind of asset the Maker is committed to trade. Assets could include fungible tokens (ERC20), non-fungible tokens (ERC721), or bundles of assets (ERC1155).
- The order is hashed, and the Maker signs the order to cryptographically commit to the order they authored.
- The order is shared with counter-parties.
- If the Maker of the 0x order already knows their desired counter-party, they can send the order directly (via email, chat, or over-the-counter platform)
- If the Maker doesn’t know a counter-party willing to take the trade, they can submit the order to orderbook.
- 0x API aggregates liquidity across all the supply sources to surface the best price for the order to the Taker. 0x helps traders create, find, and fill the 0x orders through the paradigm of off-chain relay and on-chain settlement. This means that 0x does not store orders on the blockchain; instead, orders are stored off-chain, and trade settlement only occurs on-chain. This unique feature makes 0x a flexible and gas-efficient DEX protocol for developers to build on.
- The Taker fills the 0x order by submitting the order and the amount they will fill it for to the blockchain.
- The 0x Protocol’s settlement logic verifies the Maker’s digital signature and that all the conditions of the trade are satisfied. If so, the assets involved are atomically swapped between Maker and Taker. If not, the trade is reverted.
What can I build on 0x?
Below is a non-exhaustive list of projects that have been built on 0x. Note that 0x can also be integrated into any existing application where exchange is not the core purpose of the application. For more examples this blog post.
2Demand (Takers)
- Exchanges
- A decentralized exchange for X asset on Y market
- An Ebay-style marketplace for digital goods
- An over-the-counter (OTC) trading desk
- Wallets
- Digital wallets whose users want to exchange tokens
- Options and derivatives platform
- A DeFi protocol that needs liquidity and exchange to function (e.g. a derivatives, lending, or options protocol)
- Portfolio managers
- Prediction markets
- Non-fungible tokens (NFT) Exchange
- NFT marketplace
- Games with in-game currencies or items
- Investment strategies (e.g. DeFi index funds, DCA apps)
- Data
- 0x multi-chain analytics portal
- Real-time trades panel w/ GraphQL wrappers
1Supply (Makers)
- Orderbook models
- Automatic Market Makers (AMM) models
- Market Makers
- A market making or arbitrage trading bot
Guides
This page lists the most popular guides to get started building with 0x based on your use case
Swap API
Easily add liquidity aggregation into your app with a single API. Access 100+ exchanges and thousands of tokens with the Swap API.
Code Examples
- (Next.js) 0x Demo App – Example ERC20 swapping app made with 0x Swap API, Next.js, and ConnectKit
- (HTML, CSS, Javascript) 0x Demo App
- https://github.com/0xProject/0x-starter-project – A project showcasing the 0x v4 protocol through a collection of runnable examples.
Tutorials
- How to Use Swap API – This guide will teach you how to programmatically execute a ERC20 token trade.
- Build a Token Swap Dapp With Next.js, 0x, ConnectKit – A video walk-through covering core developer concepts important when building any token swapping dapp.
- How to Build a Token Swap dApp with 0x API – Written and video content on how to build a token swapping dapp (a simple Matcha.xyz) using the Swap API. This dApp aggregates liquidity across the greater DEX ecosystem surfaces the best price to the user.
- Use 0x API Liquidity in Your Smart Contracts – This guide will teach you how to consume 0x API swap quotes from inside a smart contract.
- Working in the Testnet – Learn two ways to test swapping ERC20 tokens with the 0x API – either using the Goerli testnet or forking Ethereum mainnet into your own testnet. Includes a runnable example.