DeFi API

šŸš§

DeFi API is in a closed beta

If you want to participate, submit your request.

Overview

DeFi API is the Chainstack suite of tools that provides access to real-time and historical data from DeFi protocols. This data is crucial for monitoring and analyzing DeFi activities and making informed decisions within the DeFi space.

DeFi protocols enable various financial services such as lending, borrowing, trading, and yield farming. Via Chainstack DeFi API, you can access such protocols as Uniswap, SushiSwap, Lido, Aave, OpenSea, and more.

Access to DeFi protocols is facilitated through a GraphQL API based on The Graph standard, and the DeFi API itself relies on subgraphs. Additionally, you can use the GraphQL visual interface to compose and execute GraphQL queries.

Basic DeFi API workflow

When accessing DeFi API for an exact protocol, you use a preset subgraph created specifically for that purpose. To use one of the DeFi API protocols, you do the following:

  1. Using the left navigation menu, go to Data APIs.
  2. From the list, open the protocol you are interested in querying.
  3. Copy either the protocol's Query URL or GraphQL UI URL. They are means that you will use to query the protocol.

To interact with the protocol, you can choose from either of the following Access options:

  • Query URL ā€” use this URL to query in the CLI or incorporate it into your code.
  • GraphQL UI URL ā€” use this URL to query in the GraphQL UI in your browser.

For examples of using both of these endpoints, see Query a subgraph.

Creating queries with GraphQL UI

Each of the protocols available in DeFi API has a preset subgraph schema which you can use to create effective queries and use them within your DApps. To learn the schema of the protocol, do the following:

  1. Copy the GraphQL UI URL from the protocol details page and paste it into your browser.
  2. In the page opened, select Explorer.
  3. In the left pane that opened, explore the interactive schema and use it to create a custom query.