저번에 쓴 글 [SCT 리치리스트 등 스팀엔진 데이터 가져다 쓰기 개발 방법론 및 샘플코드](https://www.steemcoinpan.com/sct/@morning/6r2inf-sct) 에서 너무 주먹구구식으로 암중모색 하듯 짰는데 https://github.com/harpagon210/sscjs 공식 툴이 있어서 이번에 잘 이용해서 coin-on 업데이트를 했습니다. 근데 너무 README.md 설명이 부족해 보여서 샘플코드 위주로 보충해봅니다. ## API Endpoint URL 기트허브 readme에 보면 아래처럼 나와있던데 ### In node.js ~~~ const SSC = require('sscjs'); const ssc = new SSC('https://testapi.steem-engine.com'); ssc.stream((err, res) => { console.log(err, res); }); ~~~ 저렇게만 써놓으면 안되죠. 테스트용 Endpoint URL 만 써놓으면 프로덕션용 Endpoint 는 본능적인 감으로 찍어서 맞춰보란 소리인가? ~~~ const ssc = new SSC('https://api.steem-engine.com/rpc/'); ~~~ 이게 프로덕션 엔드포인트 입니다. 그 외에도 부실한 설명에 불만이 많았지만, 이정도로 자제하고 원래 쓰려던 내용에만 충실하게 써봅니다. ## 토큰 보유자 현황 ~~~~ ssc.find( 'tokens', //contract name 'balances', //table name {'symbol':'SCT'}, //query to perform on the table 1000, //limit the number of records to retrieve 0, //offset applied to the records set [], //array of index definitions { index: string, descending: boolean } (err, results) => { //callback console.log(err, results); }); 결과: [ { account: 'sct', symbol: 'SCT', balance: '133.440', stake: '13662.827', delegatedStake: '0', receivedStake: '0', pendingUnstake: '0', '$loki': 34165 }, ... 566 more items ] ~~~~ 이렇게만 해도 결과는 성공적으로 나옵니다. tokens 컨트랙(=namespace 개념인듯) 의 balances 테이블에서 symbol 이 'SCT' 인 것들을 다 찾는 쿼리. ### stake 가 50000 이상인 것으로 걸러봅니다. ~~~~ ssc.find( 'tokens', //contract name 'balances', //table name {'symbol':'SCT', 'stake': {$gte: 50000}}, //query to perform on the table 1000, //limit the number of records to retrieve 0, //offset applied to the records set [], //array of index definitions { index: string, descending: boolean } (err, results) => { //callback console.log(err, results); }); 결과: [ { account: 'jack8831', symbol: 'SCT', balance: '114.959', stake: '87832.618', delegatedStake: '0', receivedStake: '0', pendingUnstake: '0', '$loki': 34205 }, { account: 'ramires', symbol: 'SCT', balance: '0.000', stake: '104801.708', delegatedStake: '0', receivedStake: '0', pendingUnstake: '0', '$loki': 34497 }, { account: 'kopasi', symbol: 'SCT', balance: '0.000', stake: '116838.158', delegatedStake: '0', receivedStake: '0', pendingUnstake: '0.000', '$loki': 34534 }, { account: 'jjm13', symbol: 'SCT', balance: '335.935', stake: '58500.400', delegatedStake: '0', receivedStake: '0', pendingUnstake: '0', '$loki': 34607 } ] ~~~~ $gte 는 Greater Than or Equal to, 이상 $gt 는 Greater Than, 초과 ### or 검색 stake 가 1 이상이거나 balance 가 1 이상이거나 pendingStake 가 1 이상인 결과물 찾기 ~~~~ ssc.find( 'tokens', //contract name 'balances', //table name { 'symbol':'SCT', '$or': [ {'stake': {$gte: 1}}, {'balance': {$gte: 1}}, {'pendingUnstake': {$gte: 1}} ] }, 1000, //limit the number of records to retrieve 0, //offset applied to the records set [], //array of index definitions { index: string, descending: boolean } (err, results) => { //callback console.log(err, results); }); ~~~~ ## 마켓 오더북 ~~~~ ssc.find( 'market', 'buyBook', {'symbol': 'SCT'}, 200, 0, [{'index': 'price', 'descending': true}], (e, buyBook) => { for (var i = 0; i < buyBook.length;i++){ var buy = buyBook[i]; console.log(buy); } }); ssc.find( 'market', 'sellBook', {'symbol': 'SCT'}, 200, 0, [{'index': 'price', 'descending': false}], (e, sellBook) => { for (var i = 0; i < sellBook.length;i++){ var sell = sellBook[i]; console.log(sell); } }); ~~~~ [{'index': 'price', 'descending': true}] 이런식으로 해서 price 순으로 정렬해줍니다. ## 거래 기록 ~~~~ ssc.find( 'market', 'tradesHistory', {'symbol': 'SCT'}, 200, 0, [{"index":"timestamp","descending":false}], (err, results) => { }); ~~~~ timestamp 순으로 정렬해야 스팀엔진 마켓과 비슷한 결과가 나옵니다.
author | morning |
---|---|
permlink | sscjs-steem-engine-api |
category | sct |
json_metadata | {"tags":["sct","kr-dev"],"links":["https://www.steemcoinpan.com/sct/@morning/6r2inf-sct","https://github.com/harpagon210/sscjs"],"app":"steemcoinpan/0.1","format":"markdown"} |
created | 2019-06-15 15:14:21 |
last_update | 2019-06-15 15:19:36 |
depth | 0 |
children | 6 |
last_payout | 2019-06-22 15:14:21 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 6.926 HBD |
curator_payout_value | 1.965 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 3,859 |
author_reputation | 120,327,679,023,535 |
root_title | "sscjs 를 이용한 steem-engine API 샘플코드 - 토큰 보유자 현황(리치리스트), 마켓 오더북, 거래기록" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 86,681,486 |
net_rshares | 15,861,673,835,194 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
ajvest | 0 | 88,864,238,016 | 50% | ||
vip | 0 | 11,711,821,213 | 100% | ||
woo7739 | 0 | 1,684,110,376,489 | 100% | ||
cheolwoo-kim | 0 | 22,812,715,846 | 50% | ||
morning | 0 | 412,049,804,505 | 100% | ||
toxonaut | 0 | 480,918,411 | 90% | ||
bullionstackers | 0 | 6,849,506,657 | 1% | ||
oldstone | 0 | 2,671,477,507,146 | 51% | ||
jack8831 | 0 | 77,567,668,828 | 100% | ||
arama | 0 | 5,203,373,603,085 | 100% | ||
kuri12 | 0 | 4,255,474,602 | 100% | ||
twinbraid | 0 | 432,946,508,159 | 100% | ||
abdullar | 0 | 128,117,641,952 | 100% | ||
bukiland | 0 | 1,207,259,078 | 3.14% | ||
magical-salt | 0 | 26,936,100,422 | 81% | ||
ramires | 0 | 322,224,544,810 | 30% | ||
elviento | 0 | 1,966,508,938 | 1.47% | ||
odongdang | 0 | 34,325,427,200 | 100% | ||
yoon | 0 | 93,574,220,278 | 55% | ||
hwan100 | 0 | 428,325,894,393 | 40% | ||
skan | 0 | 624,098,120,035 | 24% | ||
lonose | 0 | 36,195,661,241 | 100% | ||
sonamoo | 0 | 20,454,146,279 | 100% | ||
happyberrysboy | 0 | 71,572,341,370 | 100% | ||
jkkim | 0 | 25,754,755 | 10% | ||
vimva | 0 | 34,873,486,660 | 100% | ||
jhy2246 | 0 | 15,836,091,208 | 10% | ||
happyworkingmom | 0 | 899,974,099,737 | 100% | ||
stylegold | 0 | 2,306,690,529 | 100% | ||
realmankwon | 0 | 20,086,447,244 | 100% | ||
ricko66 | 0 | 41,132,383,555 | 100% | ||
jjg | 0 | 190,116,427,617 | 100% | ||
tookta | 0 | 105,389,973,351 | 100% | ||
molamola | 0 | 1,530,018,220 | 100% | ||
storysharing | 0 | 23,474,549,246 | 100% | ||
yangpankil27 | 0 | 76,298,612,819 | 50% | ||
beom | 0 | 494,575,159 | 100% | ||
tkdgjs79 | 0 | 2,876,132,214 | 100% | ||
goodhello | 0 | 33,381,309,864 | 50% | ||
roostermine | 0 | 7,717,087,840 | 49% | ||
eversloth | 0 | 344,397,506,309 | 100% | ||
jacobyu | 0 | 63,153,499,258 | 100% | ||
songa0906 | 0 | 24,568,227,079 | 100% | ||
muwon123 | 0 | 510,613,442,282 | 100% | ||
ayogom | 0 | 11,226,494,971 | 50% | ||
rainingfall | 0 | 14,374,314,766 | 80% | ||
photoholic | 0 | 694,502,645 | 100% | ||
onehand | 0 | 1,161,814,045 | 20% | ||
totopapa | 0 | 13,084,624,378 | 100% | ||
daycaredave | 0 | 165,100,584 | 100% | ||
lovelyyeon | 0 | 43,134,269,131 | 100% | ||
donekim | 0 | 59,323,226,726 | 100% | ||
zzing | 0 | 13,178,763,466 | 100% | ||
naha | 0 | 110,806,827,487 | 21% | ||
jungch98 | 0 | 1,675,483,555 | 100% | ||
sinta2 | 0 | 802,661,506 | 100% | ||
molang | 0 | 170,534,654 | 100% | ||
blockchainstudio | 0 | 171,661,053,841 | 100% | ||
kinojun | 0 | 478,446,559 | 100% | ||
ziq | 0 | 3,199,987,872 | 100% | ||
anpigon | 0 | 25,966,450,337 | 100% | ||
china-mobile | 0 | 546,264,070 | 100% | ||
winston80 | 0 | 21,597,258,026 | 100% | ||
pager | 0 | 201,588,847 | 10% | ||
parisfoodhunter | 0 | 36,197,095,200 | 50% | ||
tiffany4ever | 0 | 225,122,597 | 30% | ||
deralios | 0 | 179,203,775 | 100% | ||
influencer07 | 0 | 2,922,100,592 | 100% | ||
bluengel | 0 | 3,477,094,244 | 2.5% | ||
laissez-faire | 0 | 24,264,068 | 100% | ||
djusti | 0 | 235,828,965,232 | 22% | ||
honeybeerbear | 0 | 20,303,401,965 | 100% | ||
kr-curator | 0 | 64,746,121 | 13.5% | ||
deer3 | 0 | 18,713,531,895 | 100% | ||
bewarecenterbase | 0 | 50,383,888,482 | 26% | ||
new-jersey | 0 | 8,564,876,085 | 100% | ||
chocolatelover | 0 | 2,535,033,468 | 100% | ||
leeyh2 | 0 | 3,330,751,309 | 100% | ||
dorian-dev | 0 | 5,372,424,432 | 100% | ||
sct.cu1 | 0 | 10,719,759,439 | 51% | ||
sct.cu2 | 0 | 22,908,034,907 | 100% | ||
sct.cu4 | 0 | 9,450,507,428 | 45% | ||
sct.cu5 | 0 | 11,595,413,672 | 50% | ||
sct.cu6 | 0 | 10,001,337,405 | 100% | ||
sct.cu8 | 0 | 19,100,314,936 | 100% | ||
sct.cu9 | 0 | 15,268,114,118 | 100% | ||
sct.cu11 | 0 | 2,833,702,443 | 15% | ||
sct.cu14 | 0 | 19,823,518,208 | 100% | ||
sct.cu15 | 0 | 8,945,681,637 | 100% | ||
sct.cu16 | 0 | 10,269,880,304 | 50% | ||
sct.cu19 | 0 | 18,267,325,554 | 100% | ||
buchheim | 0 | 746,447,812 | 51% | ||
sct.kop3 | 0 | 2,610,503,038 | 100% | ||
lovelyyeon.sct | 0 | 1,592,048,678 | 100% | ||
feelsogood.cur | 0 | 9,553,704,369 | 50% | ||
qyanomou | 0 | 542,606,117 | 100% | ||
sct.jcob | 0 | 1,063,262,863 | 100% | ||
jstory | 0 | 499,383,440 | 30% | ||
darc | 0 | 395,980,981 | 91% | ||
wonsama.sct | 0 | 169,817,015 | 20% |
개알못 이라 어렵지만, (코딩 알못 하려했더니, 코인 알못과 헷깔려서, 개알못 개발 알못으로.. 코인도 모르긴 하지만요..) 일단 뭔가 있는 것을 접수..
author | bewarecenterbase |
---|---|
permlink | re-morning-sscjs-steem-engine-api-20190616t035058910z |
category | sct |
json_metadata | {"tags":["sct"],"app":"steemcoinpan/0.1"} |
created | 2019-06-16 03:51:00 |
last_update | 2019-06-16 03:51:00 |
depth | 1 |
children | 0 |
last_payout | 2019-06-23 03:51:00 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.058 HBD |
curator_payout_value | 0.019 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 87 |
author_reputation | -93,249,918,891,757 |
root_title | "sscjs 를 이용한 steem-engine API 샘플코드 - 토큰 보유자 현황(리치리스트), 마켓 오더북, 거래기록" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 86,704,897 |
net_rshares | 132,465,539,859 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
bewarecenterbase | 0 | 132,465,539,859 | 100% |
수고 많으셨습니당~💙 감사합니다~💙 행복한 💙 오늘 보내셔용~*^^* Posted using [Partiko Android](https://partiko.app/referral/bluengel)
author | bluengel |
---|---|
permlink | bluengel-re-morning-sscjs-steem-engine-api-20190617t010844514z |
category | sct |
json_metadata | {"app":"partiko","client":"android"} |
created | 2019-06-17 01:08:45 |
last_update | 2019-06-17 01:08:45 |
depth | 1 |
children | 0 |
last_payout | 2019-06-24 01:08:45 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 110 |
author_reputation | 129,269,571,273,945 |
root_title | "sscjs 를 이용한 steem-engine API 샘플코드 - 토큰 보유자 현황(리치리스트), 마켓 오더북, 거래기록" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 86,748,927 |
net_rshares | 0 |
포스팅 잘 보았습니다~! 많은 도움이 될것 같아요~~!! 또 궁금한게 sellBook, tradesHistory같이 테이블명이 따로 공개 된게 있나요?
author | honeybeerbear |
---|---|
permlink | re-morning-sscjs-steem-engine-api-20190616t003203331z |
category | sct |
json_metadata | {"tags":["sct"],"app":"steemcoinpan/0.1"} |
created | 2019-06-16 00:32:03 |
last_update | 2019-06-16 00:32:03 |
depth | 1 |
children | 2 |
last_payout | 2019-06-23 00:32:03 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 84 |
author_reputation | 43,415,437,983,715 |
root_title | "sscjs 를 이용한 steem-engine API 샘플코드 - 토큰 보유자 현황(리치리스트), 마켓 오더북, 거래기록" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 86,700,970 |
net_rshares | 0 |
market 컨트랙에 metrics 테이블 tokens 컨트랙에 contractsBalances, pendingUnstakes 테이블 있네요
author | morning |
---|---|
permlink | re-honeybeerbear-re-morning-sscjs-steem-engine-api-20190616t153829202z |
category | sct |
json_metadata | {"tags":["sct"],"app":"steemcoinpan/0.1"} |
created | 2019-06-16 15:38:30 |
last_update | 2019-06-16 15:38:48 |
depth | 2 |
children | 1 |
last_payout | 2019-06-23 15:38:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.015 HBD |
curator_payout_value | 0.005 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 79 |
author_reputation | 120,327,679,023,535 |
root_title | "sscjs 를 이용한 steem-engine API 샘플코드 - 토큰 보유자 현황(리치리스트), 마켓 오더북, 거래기록" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 86,729,386 |
net_rshares | 36,837,293,057 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
honeybeerbear | 0 | 36,837,293,057 | 100% |
답변 감사드립니다~~
author | honeybeerbear |
---|---|
permlink | re-morning-re-honeybeerbear-re-morning-sscjs-steem-engine-api-20190617t084949882z |
category | sct |
json_metadata | {"tags":["sct"],"app":"steempeak/1.11.1"} |
created | 2019-06-17 08:49:48 |
last_update | 2019-06-17 08:49:48 |
depth | 3 |
children | 0 |
last_payout | 2019-06-24 08:49:48 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 11 |
author_reputation | 43,415,437,983,715 |
root_title | "sscjs 를 이용한 steem-engine API 샘플코드 - 토큰 보유자 현황(리치리스트), 마켓 오더북, 거래기록" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 86,769,253 |
net_rshares | 0 |
코딩을 봐도 어떻게 해야하는지 모르겠지만 T.T 결과물들 감사히 잘쓰고 있습니다. 편안한 휴일되세요~
author | lovelyyeon.sct |
---|---|
permlink | re-morning-sscjs-steem-engine-api-20190615t192015881z |
category | sct |
json_metadata | {"tags":["sct"],"app":"steemcoinpan/0.1"} |
created | 2019-06-15 19:20:30 |
last_update | 2019-06-15 19:20:30 |
depth | 1 |
children | 0 |
last_payout | 2019-06-22 19:20:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 56 |
author_reputation | 371,686,959,467,496 |
root_title | "sscjs 를 이용한 steem-engine API 샘플코드 - 토큰 보유자 현황(리치리스트), 마켓 오더북, 거래기록" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 86,691,243 |
net_rshares | 0 |