STEEM API 系列之获取货币转换 - Steem API/converter (SBD, STEEM, VESTS)

in #cn7 years ago (edited)

We have so many concepts in STEEMIT namely: SBD, STEEM, STEEM POWER (SP) and VESTS. There are conversions between them. For instances:

  • How much SBD can we get per STEEM?
  • How much STEEM per SBD?
  • 1 SP = ? VESTS
  • 1M VESTS = ? STEEM
  • 1 VESTS = ? STEEM POWER
  • What is the current median price of SBD?

I have added an handy API to fetch all these data, which now is deployed to four API servers world wide:

An example to invoke the API on the Linux Bash:
curl -s -X GET "https://helloacm.com/api/steemit/converter/?cached"

That returns the JSON key-pairs

{
"steem_to_sbd": 1.084,
"sbd_to_steem": 0.9225092250922509, 
"sp_to_vests": 2059.117814239809, 
"steem_per_mvests": 485.64486844050873, 
"vests_to_sp": 0.0004856448684405087, 
"sbd_median_price": 1.084
}

The results are cached and updated every hour. Using our favorite programming language PHP, this can be pretty easy to use:

<?php
   $converter = json_decode(file_get_contents("https://helloacm.com/api/steemit/converter/?cached"), true);
   echo "1 STEEM = ". $converter['steem_to_sbd']. " SBD";

STEEMIT 有 SBD、STEEM、STEEM POWER 还有 VESTS这几个概念。时不时,我们就需要知道它们之间几个转换关系:

  • 1个STEEM等于多少SBD?
  • 1个SBD 等于多少STEEM?
  • 1个SP等于多少VESTS?
  • 1M的VESTS 等于多少STEEM?
  • 1个VESTS等于多少STEEM POWER?
  • SBD的中位价?

这下好了,我把这些都整理成一个API,放在四个服务器上:

举例,在SHELL下执行命令:
curl -s -X GET "https://helloacm.com/api/steemit/converter/?cached"

返回JSON数据:

{
"steem_to_sbd": 1.084,
"sbd_to_steem": 0.9225092250922509, 
"sp_to_vests": 2059.117814239809, 
"steem_per_mvests": 485.64486844050873, 
"vests_to_sp": 0.0004856448684405087, 
"sbd_median_price": 1.084
}

API结果每小时更新结果一次。这下方便多了,啥语言想知道结果也就一两句话的事情,比如用我们最喜爱的PHP

<?php
   $converter = json_decode(file_get_contents("https://helloacm.com/api/steemit/converter/?cached"), true);
   echo "1 STEEM = ". $converter['steem_to_sbd']. " SBD";

@justyy 是CN 区的点赞机器人,对优质内容进行点赞,只要代理给 @justyy 每天收利息(100 SP 每天0.04 SBD)并且能获得一次相应至少2倍的点赞,可以认为是VP 200%+ ,详细请看:


欢迎你发表你的见解和看法,特别有意思的评论我可能会奖励你1 SBD哦。
Interesting Comments might be rewarded with 1 SBD.

Sort:  

没法评论啊 我为对程序一窍不通

头像好美。^_^

我想发个贴,集资整容,让大家给我捐捐款.

哇哈哈 有想法

等我整完我就比你好看了哈哈哈

这……万一失败了呢

姐,你太可爱啦

求高清头像

来四川。四川美女夹道欢迎,个个高清头像

This post recieved an upvote from minnowpond. If you would like to recieve upvotes from minnowpond on all your posts, simply FOLLOW @minnowpond

Coin Marketplace

STEEM 0.17
TRX 0.15
JST 0.028
BTC 60228.69
ETH 2428.23
USDT 1.00
SBD 2.45