Start Building on the DIA Oracle and API

Documentation

Find all relevant information to start building a variety of financial dApps with DIA Oracles and APIs, a reliable and verifiable bridge between off-chain data from various sources and on-chain smart contracts.

Cross-Chain Oracle Delivery

DIA operates oracles on multiple blockchains and access data from multiple and transparent sources.

Binance Smart Chain logo

Example: Ethereum Oracle

This smart contract holds mappings from an index to an asset’s name, its price value, and – if applicable – supply data. By using the read function getCoinInfo(coin_name) it is possible to retrieve this data. Along with the actual data there is a metadata field for the timestamp of the last update.

/**
 *Submitted for verification at Etherscan.io on 2018-10-25
*/

pragma solidity ^0.4.21;

contract DiaOracle {
  address owner;

  struct CoinInfo {
    uint256 price;
    uint256 supply;
    uint256 lastUpdateTimestamp;
    string symbol;
  }

  mapping(string => CoinInfo) diaOracles;
  
  event newCoinInfo(
    string name,
    string symbol,
    uint256 price,
    uint256 supply,
    uint256 lastUpdateTimestamp
  );
    
  constructor() public {
    owner = msg.sender;
  }

  function changeOwner(address newOwner) public {
    require(msg.sender == owner);
    owner = newOwner;
  }
    
  function updateCoinInfo(string name, string symbol, uint256 newPrice, uint256 newSupply, uint256 newTimestamp) public {
    require(msg.sender == owner);
    diaOracles[name] = (CoinInfo(newPrice, newSupply, newTimestamp, symbol));
    emit newCoinInfo(name, symbol, newPrice, newSupply, newTimestamp);
  }
    
  function getCoinInfo(string name) public view returns (uint256, uint256, uint256, string) {
    return (
      diaOracles[name].price,
      diaOracles[name].supply,
      diaOracles[name].lastUpdateTimestamp,
      diaOracles[name].symbol
    );
  }
}
Information:
Get the most recent price and circulation supply information on the desired currencies by inputing the corresponding full coin name.
Required parameters:
coin_name (String)
Request example:
Current price
0
Current circulation supply
0
UNIX Timestamp
0
Asset short name
-

API Endpoints Overview

Whether you’re building a financial service, a portfolio management tool, a new media offering, or anything else, DIA provides the most advanced and updated data on the market for your product.

Examples

Find below a few examples of API Endpoints.

Information:
Get the most recent price information on the desired currencies by inputing the corresponding currency symbol.
Required parameters:
Symbol (String)
Request example:
Information:
Get a list of all available crypto exchanges.
Request example:
Information:
Get the most recent information on a specific farming pool, such as pool rate and pool balance.
Path parameters: (required)
Protocol (String)
PoolID (String)
Path parameters:
DateInit (Integer)
DateFinal (Integer)
Request example:
Information:
Get information about a Defi protocol's lending and borrowing rates. Time parameter is optional. If omitted, the most recent rate is returned.
Path parameters: (required)
Protocol (String)
Asset (String)
Path parameters:
DateInit (Integer)
DateFinal (Integer)
Request example:

Questions

Connect with DIA developers on Discord and get help
DIA Dev team