화폐 공급을 얻으세요

Tool Extent-API
생성 날짜: 2018-10-18 15:21:42 마지막으로 수정됨: 2019-07-03 16:33:08
복사: 16 클릭수: 1982
3
집중하다
1444
수행원

코인 마켓캡이 제공하는 API 인터페이스를 사용하여 코인의 공급량과 유통량을 얻을 수 있으며, 이는 총 시장 가치를 계산할 수 있습니다.

전략 소스 코드
function GetSupply(symbol, max){
    var ids = null
    if(_G('ids')){
        ids = _G('ids')
    }else{
        ids = JSON.parse(HttpQuery('https://api.coinmarketcap.com/v2/listings/')).data
        _G('ids', ids)
    }
    var coinId = null
    for (var i=0; i<ids.length; i++){
        if(ids[i].symbol.toLowerCase() == symbol.toLowerCase() ){
            coinId = ids[i].id
            break
        }
    }
    if(coinId){
        var ticker = JSON.parse(HttpQuery('https://api.coinmarketcap.com/v2/ticker/'+ coinId + '/')).data
        return parseFloat(max == undefined ? ticker.total_supply: ticker.max_supply)
    }else{
        throw 'symbol not found'
    }
}
function main() {
    Log(GetSupply('BTC')) // Get total current supply
    Log(GetSupply('BTC', true)) // Get max supply
}