Skip to content

Commit

Permalink
documentation: Include readme, api doc
Browse files Browse the repository at this point in the history
  • Loading branch information
kaythxbye committed Oct 29, 2019
1 parent cd9147d commit cdc1c37
Show file tree
Hide file tree
Showing 2 changed files with 305 additions and 1 deletion.
213 changes: 213 additions & 0 deletions documentation/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
# DIAdata.org API

The world's crowd-driven financial data community has a professional API made for you.<br><h2>Decentral and transparent by design</h2><br>With our decentral approach to data verification, you can gain a deep insight into current and past pricing, volume and exchange info so you can make the right decisions to stay ahead of the game.<br><br><h3>Find the right data for your needs</h3><br>Show your users the most transparent data on the market with our API. Whether you're building a financial service, a portfolio management tool, a new media offering, or more, we have the most advanced and updated data on the market for your product.<br>For Oracle usage see [github](https://github.com/diadata-org/diadata/blob/master/documentation/methodology/Oracles.md).<br><br><h3>Backtest your strategies</h3><br>Use the most efficient and transparent crypto data to run simulations and backtest your trading or investing strategies. With crowd-aggregated hundreds of exchanges you can be sure that you're getting the right picture every single time.<br><br><h3>Run Experiments</h3><br>Build your own models with our data, to further your interest or just for fun. With our flexible and powerful API, we provide you with a set of data that will help you draw insights and make conclusions.<br><br><h3>Request your data</h3><br>Set a bounty on gitcoin.io or drop us [line](mailto:API@diadata.org).

Version: 1.0

## Base URL

The DIA base url is `https://api.diadata.org/`. All API paths are sub-paths of this base URL.

## Paths

### GET /v1/chartPoints/
Get chart points for.

Query Params:
- scale [string]: scale 5m 30m 1h 4h 1d 1w.

Path Params:
- symbol [string]: Some symbol.
- exchange [string]: Some exchange.
- filter [string]: Some filter.

Responses:
- 200: success.

[models.Points](#modelspoints)
- 404: Symbol not found.

[restApi.APIError](#restapiapierror)
- 500: error.

[restApi.APIError](#restapiapierror)

### GET /v1/chartPointsAllExchanges/
Get Symbol Details.

Query Params:
- scale [string]: scale 5m 30m 1h 4h 1d 1w.

Path Params:
- symbol [string]: Some symbol.
- filter [string]: Some filter.

Responses:
- 200: success.

[models.Points](#modelspoints)
- 404: Symbol not found.

[restApi.APIError](#restapiapierror)
- 500: error.

[restApi.APIError](#restapiapierror)

### GET /v1/coins
Get coins.

Responses:
- 200: success.

[models.Coins](#modelscoins)
- 500: error.

[restApi.APIError](#restapiapierror)

### GET /v1/pairs/
Get pairs.

Responses:
- 200: success.

[models.Pairs](#modelspairs)
- 500: error.

[restApi.APIError](#restapiapierror)

### GET /v1/quotation/
Get quotation.

Path Params:
- symbol [string]: Some symbol.

Responses:
- 200: success.

[models.Quotation](#modelsquotation)
- 404: Symbol not found.

[restApi.APIError](#restapiapierror)
- 500: error.

[restApi.APIError](#restapiapierror)

### POST /v1/supply

Post the circulating supply.

Query Params:
- Symbol [string]: Coin symbol.
- CirculatingSupply [number]: number of coins in circulating supply.

Responses:
- 200: success.

[dia.Supply](#diasupply)
- 500: error.

[restApi.APIError](#restapiapierror)

### GET /v1/supply/

Get supply.

Path Params:
- symbol [string]: Some symbol.

Responses:
- 200: success.

[dia.Supply](#diasupply)
- 404: Symbol not found.

[restApi.APIError](#restapiapierror)
- 500: error.

[restApi.APIError](#restapiapierror)

### GET /v1/symbol/
Get Symbol Details.

Path Params:
- symbol [string]: Some symbol.

Responses:
- 200: success.

[models.SymbolDetails](#modelssymboldetails)
- 404: Symbol not found.

[restApi.APIError](#restapiapierror)
- 500: error.

[restApi.APIError](#restapiapierror)

### GET /v1/symbols

Get all symbols list.

Query Params:
- scale [string]: scale 5m 30m 1h 4h 1d 1w.

Path Params:
- symbol [string]: Some symbol.
- filter [string]: Some filter.

Responses:
- 200: success.

[dia.Symbols](#diasymbols)
- 500: error.

[restApi.APIError](#restapiapierror)


## Definitions


### dia.Pair

- exchange *(string)* - foreignName *(string)* - ignore *(boolean)* - symbol *(string)*
### dia.Supply

- block *(integer)* - circulatingSupply *(number)* - name *(string)* - source *(string)* - symbol *(string)* - time *(string)*
### dia.Symbols

- symbols *(array)* - type: string
### dia.Trade

- estimatedUSDPrice *(number)* - foreignTradeID *(string)* - pair *(string)* - price *(number)* - source *(string)* - symbol *(string)* - time *(string)* - volume *(number)*
### models.Change

- usd *(array)* - [models.CurrencyChange](#modelscurrencychange)
### models.Coin

- circulatingSupply *(number)* - name *(string)* - price *(number)* - priceYesterday *(number)* - symbol *(string)* - time *(string)* - volumeYesterdayUSD *(number)*
### models.Coins

- change *(object)* - coins *(array)* - [models.Coin](#modelscoin) - completeCoinList *(array)* - [models.CoinSymbolAndName](#modelscoinsymbolandname)
### models.CoinSymbolAndName

- name *(string)* - symbol *(string)*
### models.CurrencyChange

- rate *(number)* - rateYesterday *(number)* - symbol *(string)*
### models.Pairs

- pairs *(array)* - [dia.Pair](#diapair)
### models.Points

- dataPoints *(string)*
### models.Quotation

- name *(string)* - price *(number)* - priceYesterday *(number)* - source *(string)* - symbol *(string)* - time *(string)* - volumeYesterdayUSD *(number)*
### models.SymbolDetails

- change *(object)* - coin *(object)* - exchanges *(array)* - [models.SymbolExchangeDetails](#modelssymbolexchangedetails) - gfx1 *(object)* - rank *(integer)*
### models.SymbolExchangeDetails

- lastTrades *(array)* - [dia.Trade](#diatrade) - name *(string)* - price *(number)* - priceYesterday *(number)* - time *(string)* - volumeYesterdayUSD *(number)*
### restApi.APIError

- errorcode *(integer)* - errormessage *(string)*
93 changes: 92 additions & 1 deletion documentation/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,94 @@
# DIA data documentation

some index site content
Welcome to the [DIAdata.org](https://diadata.org/) platform.
DIA is an ecosystem for open financial data in a financial smart contract ecosystem.
The target of DIA is to bring together data analysts, data providers and data users.
In general, DIA provides a reliable and verifiable bridge between off-chain data from various sources and on-chain smart contracts that can be used to build a variety of financial dApps.
![DIA Overview](assets/DIA-Architecture.png)

### Decentralized Financial Data
All DIA data points can be used in Ethereum Smart Contracts.
We provide oracle solutions to use this financial information in any smart contract.
The correctness of oracle data can always be verified by monitoring our off-chain real-time API and the data published in the oracle.

## Alpha Version - dApp Registry
* [CoinHub](http://coinhub.diadata.org) - A transparent, open-source alternative to CMC
* [Neufund](https://blog.neufund.org/neufund-1-1-is-live-on-mainnet-db35d77b2ef2)
* [Helena/Consensys](https://helena.network) - Delivering real-time blockchain fundamental insights
* [Open-Source Calculation Agent](https://blockstate.com/decentral-calculation-agent/)
* [Swiss ISIN note using DIA data](https://en.bitcoinwiki.org/wiki/Index_Fund)

## Methodology Documentation
Currently, DIA collects several classes of data.
Separate documentation exists for each of these different use cases.

* [Exchange Scrapers](documentation/methodology/ExchangePrices.md) are the components that get trade data from various exchanges and use these trades to construct average prices.
* [Supply Scrapers](documentation/methodology/SupplyNumbers.md) are used to determine circulating supply numbers for cryptocurrency assets.
* [Oracles](documentation/methodology/Oracles.md) show how our oracles can be accessed.
This information varies for each currency and is highly specific.

## Coinhub Oracles

The Coinhub oracles are located in a [single smart contract](https://etherscan.io/address/0xD47FDf51D61c100C447E2D4747c7126F19fa23Ef).
This smart contract holds mappings from an index to an asset's name, its price, and supply data.
By using `getParameters(asset_index)` it is possible to retrieve this data.
Along with the actual data there is a metadata field for the timestamp of the last update.

Updates are supplied by the DIA Oracle service that periodically supplies updates into the smart contract.
In the event view, the latest updates can be seen.
The event fields show the values in the following locations:

* Price in Cent is in the second field (display as `number`)
* Supply is in the third field (display as `number`)
* UNIX Timestamp of last update is displayed in the fourth field (display as `number`)
* Name is displayed in the sixth and last field (display as `text`).

## API Access
You can find documnentation for our [live API](https://api.diadata.org/v1) on our [api documentation site](documentation/api.md).
Several endpoints exist that show the different kind of data we collect:

When referencing currencies, `{TLA}` has to be replaced by the acronym for an asset (e.g., BTC for Bitcoin).
* Quotations for prices (SMA120) can be found at endpoint [https://api.diadata.org/v1/symbol/BTC](https://api.diadata.org/v1/symbol/BTC).
* Supply data for crypto assets is located at [https://api.diadata.org/v1/supply/BTC](https://api.diadata.org/v1/supply/BTC)

Currently, DIA collects data from several crypto exchanges.
To get an overview, the latest information about these exchanges can be found in this table:

Name | Number of Pairs | API link
--- | --- | ---
Binance | [47](config/Binance.json) | [Binance API Documentation](https://github.com/binance-exchange/binance-official-api-docs)
Bitfinex | [25](config/Bitfinex.json) | [Bitfinex Websocket Documentation](https://docs.bitfinex.com/docs/ws-general)
Coinbase | [3](config/CoinBase.json) | [Coinbase v2 API](https://developers.coinbase.com/api/v2)
GateIO | [42](config/GateIO.json) | [Gate.io API Documentation](https://www.gate.io/api2)
HitBTC | [43](config/HitBTC.json) | [HitBTC API Browser](https://api.hitbtc.com/api/2/explore/)
Huobi | [40](config/Huobi.json) | [Huobi API Documentation](https://github.com/huobiapi/API_Docs_en/wiki/Huobi.pro-API)
Kraken | [8](config/Kraken.json) | [Kraken Public API Documentation](https://www.kraken.com/help/api#public-market-data)
LBank | [20](config/LBank.json) | [LBank API Documentation (Chinese)](https://github.com/LBank-exchange/lbank-official-api-docs)
OKEx | [27](config/OKEx.json) | [OKEx API Documentation (Chinese)](https://github.com/okcoin-okex/API-docs-OKEx.com)
Simex | [14](config/Simex.json) | [Simex API Documentation](https://simex.global/en/docs/introduction)
ZB.com | [127](config/ZB.json) | [Zb.com API Documentation (Chinese)](https://www.zb.com/i/developer)

Here you can find the introduction to the structure of the system and first steps to contribute.

## DIA Technical Structure
DIA is setup as a hybrid system with off-chain components for storing and proceccing large amounts of data and on-chain components providing data sources for financial smart contracts.
Currently, Ethereum is used as smart contract plaform because of its widespread use and technical quality, but the DIA system is not limited to one blockchain technology.

### Centralized Backend
For collecting financial data, we use a centralized backend that runs collectors for all kinds of financial data.
All collected data is processed by a database setup consisting of a stream-oriented kafka instance and a key-value store for faster access of certain intermediate results.
These collectors are separated in different classes:

* Exchange Scrapers: These collect data from exchanges for cryptocurrencies and other assets (like stocks, futures, and rare earth metals).
Every exchange scraper is run independently and is structured around the idea of `pairs` that are used to indicate the pair of assets that is used in a trade.
For example, a trade from Bitcoin to US-Dollar is stored under `BTCUSD`.
* Blockchain Scrapers: These scrapers are used to determine attributes of blockchains. The most prominent attribute is the circulating supply of a cryptocurrency, for which various scrapers already exist.
Depending on the expected update rate of a blockchain, these scrapers update the backend periodically about their data.
Blockchain scrapers are run as docker containers that can be managed independently.
Often, these collect Gigabytes of data over time (they are dealing with ever-growing blockchains) and thus should be managed in a separate way not directly baked in the database executable.
* Quotation Scrapers: They are used to collect official quotations from central trusted providers.
The first quotations in our database are daily exchange rates from the European Central Bank (ECB) against various international currencies.

## How to contribute
DIA is open for anyone to contribute and we always welcome pull requests.
We also provide tasks on [Gitcoin](https://gitcoin.co/), a collaboration tool focused on cryptocurrency projects.

0 comments on commit cdc1c37

Please sign in to comment.