API Documentation

Introduction

Welcome! Here we discuss how our API works and how can you integrate the API into your application to get access to all the DeFi data we have. If you want a general overview of SimpleFi, you can check out this link, and if you want to learn more about how you can integrate with Simplefi’s Subgraphs, click here.

Getting Started

Authentication

The use of our API requires authentication through and Api-key, which for the time being is free.

To create your own personal key, complete our online form here.

Once you’ve obtained an Api-key, you must attach it to the headers of each request under the header Authorization.

fetch(url, {
    headers: {
      Authorization: Bearer <my-api-key>
    }
  })

Rate limiting

Each Api-key has a personal usage of 100,000 requests a month.

Each key is also allowed 45 calls per minute.

Errors

Error CodeCode Definition
200sSuccess
400sUser Error
500sService Error

Core Services

Pricing Data

Our pricing service provides historical prices for different types of tokens:

Our endpoints receive a contract address and either the date or date range you require.

By default, the “daily” price is returned, with a timestamp of midnight UTC. You can specify the “hourly” option in the call to receive prices with a granularity of 1h for base tokens and 3h for positional tokens on the day(s) specified.

The extended option will also provide open, close, high and low prices for the day(s) specified (the reference time being midnight UTC).

Example use cases:

  • You you want to get the latest price of an LP token in order to calculate the amount you have locked in that pool.
  • You want to see the evolution of a pool’s LP token price over time.
  • You want to see how a pool’s reserves have evolved over time.

Endpoints

A full interactive documentation of service endpoints can be found here.

Core Data

In this service you can find information on all the protocols, markets and tokens (non-pricing data) that we track, as well as the subgraphs that we use.

Please note the ProtocolId is chain specific. For example, each instance of the Sushiswap DEX on different chains will have a different protocolId. Also, DEXes and their associated farms are generally considered as separate protocols (and therefore for have different protocolId’s).

Subgraphs are the primary source of onchain data we use for our APIs. These may be subgraphs developed by SimpleFi or by partners such as Messari. If you’d like your subgraph to be considered for inclusion, please contact the team on Discord!

Example use cases:

  • You require more information on a specific protocol, such as which chain it’s deployed on, it’s factory address, etc.
  • You would like to know, for a specific market, which tokens can be deposited or staked into it.
  • You’d like to know all the farms that a given LP token can be staked in. Or all the liquidity pools that a base token can be deposited in.
  • You would like to find all farms that reward the Sushi token.
  • You would like to see all the protocols that SimpleFi tracks actively.
  • You would like to find the Uniswap DEX factory contract address on Eth mainnet.

Endpoints

A full interactive documentation of service endpoints can be found here.

Chains Data

In this service you can find information on all the chains that we track, and the blocks they produce.

For blocks data, our endpoints receive a timestamp, or return the latest saved block by default. Please note that blocks are saved with a 5 minute granularity, with the same timestamp for all chains (allowing you, for example, to generate a comparable timeline for all chains with a single call). The block returned for a given timestamp will be the first block saved with a later timestamp than the one specified.

Example use cases:

  • You have a chainId and require more information on that chain (e.g. its RPC endpoint).
  • You would like to retrieve a daily timeline of block numbers for one or several chains.
  • You would like to find all blocks across the chains we track for a specific timestamp.

Endpoints

A full interactive documentation of service endpoints can be found here.