GraphQL API

Learn more about OpenTrade's graphQL API and common integration paths

Overview

The graphQL API enables users to query information on vaults, transactions, and accounts over periods of time. It also enables users to build complex queries across schemas and run those queries in a single call.

How it works

Building Queries

At the core of our graphQL API are the queries. Each query has a specific name and returns a specific data set, just like a REST endpoint.

For example, getPoolFlexAccountForDateRange returns a daily snapshot of an account for a flexible term vault over a specified period of time, while getPoolEvents returns a list of events for a given vault (e.g. deposits, withdrawals, interest accruals) etc.

But graphQL queries enables you to do a few things that REST cannot. Those are primarily

  1. You can combine multiple queries in a single call. For example, you could combine getPoolFlexAccountForDatRange and getPoolEvents into a single query and it will return a daily snapshot of the specified account for a given vault and a list of all events for that vault.

  2. You can be very specific about which information you want returned. For example, the getPoolFlexAccountForDateRange can return over 20 different fields, but you can build the query to return only the fields you care about (e.g. current balance and interest accrued).

  3. You can query data over a specified period of time, the latest data, and summary data. For example, you can use getPoolFlexAccountForDateRange query to return the closing balance on an account and interest accrued for the past 30 days, you could use getPoolFlexAccount to get the balance and interest accrued right now, or you could use getPoolFlexAccountSummaryForDateRange to return the total amount of interest accrued over the past 30 days.

When you combine all three of these capabilities, the graphQL API provides a very powerful, flexible, yet simple way to build queries for building UIs, reports, ledgers, reconciliations, and much more.

Variables

Each graphQL query requires one or more variables to be specified in the query and returns data based on the variables provided. There are four variables:

  1. poolAddr - the contract address of the vault being queried

  2. accountAddr - the wallet address of the account being queried

  3. startDayStr - the beginning of the time period for which data will be returned

  4. endDayStr - the end of the time period for which data will be returned

Not all queries require all variables. Each query will specify which variables are required.

graphQL URLs

Each environment and network has a unique URL

Environment
Network
URL

Production

Ethereum

Sandbox

Ethereum (Sepolia)

Postman

The best way to view detailed documentation and test the graphQL API is via our Postman workspace. To gain access, simply provide your email address to your account manager and you will receive an invitation to join the workspace.

For a tour of Postman and guide on how to use it, we've provided the video below.

Last updated