Here is how you can easily get a Steemit account Resource Credit amount programmatically
steemit·@gaottantacinque·
0.000 HBDHere is how you can easily get a Steemit account Resource Credit amount programmatically
https://cdn.steemitimages.com/DQmc5BTWMSBD2LhFGKFKZWcFPhjNeWt9AEykV6FTakkaEhW/image.png <center><sub>Screenshot of my script in action in the [Brave browser](https://brave.com/myc159) Console</sub></center> Tonight I read someone in a Discord channel wondering how we can programmatically read a user's RC. I could not find any documentation online, so I start researching which websites currently display a RC bar. After investigating some of their network calls without success, I started looking at their minified code and found something that seemed doing what I was looking for. After prettifying it with an online tool and digging a bit more into it I figure it out. So here it is in case you need it as well: <code><pre> var TARGET_ACCOUNT = 'cribbio'; var getResourceCredits = (user) => new Promise((resolve) => { fetch('https://api.steemit.com', { credentials: 'omit', headers: { accept: 'application/json', 'accept-language': 'en-US,en;q=0.9', 'cache-control': 'max-age=0', 'content-type': 'application/json;charset=UTF-8', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'cross-site', }, referrer: 'https://steemit.com/@marcocasario', referrerPolicy: 'no-referrer-when-downgrade', body: JSON.stringify({ id: '1', jsonrpc: '2.0', method: 'rc_api.find_rc_accounts', params: {'accounts': [user]}, }), method: 'POST', mode: 'cors', }) .then(res => res.json()) .then(({ result } = {}) => { const { rc_manabar, max_rc } = result.rc_accounts[0]; const time = Math.round((new Date).getTime() / 1e3) - rc_manabar.last_update_time; const maxMana = parseInt(max_rc); const currentMana = parseInt(rc_manabar.current_mana) + Math.round(maxMana / 432e3 * time); const percentage = Math.min(currentMana / maxMana * 100, 100); resolve(percentage); }); }); getResourceCredits(TARGET_ACCOUNT) .then((result) => console.log(TARGET_ACCOUNT, 'is at', result, '% of their RC.')); <pre><code> ----- <h4>USAGE:</h4> This is even easier than [retrieving a Steemit account information programmatically](https://steemit.com/steemit/@gaottantacinque/here-is-how-you-can-easily-get-steemit-accounts-information-programmatically) as there is no need to import SteemJs or SteemdJs. It simply uses a cross domain http requests (see [documentation on developers.steem.io](https://developers.steem.io/apidefinitions/#rc_api.find_rc_accounts)). This means that you can try this simple script in any webpage. <h5>Step by step instructions:</h5> <h4>STEP 1</h4> Open your favorite browser on any site (I strongly recommend to use [Brave browser](https://brave.com/myc159), by the way) and open the DevTools (Ctrl + Shift + J on Linux/Windows and Cmd + Opt + J on Mac). <h4>STEP 2</h4> Copy and paste my script above in the Console. <h4>STEP 3</h4> Press enter and there you go! You can now see a console log telling you the percentage of RC still available to the target user. If you want to retry with a different user simply paste the script again, change the top variable and press enter again. Enjoy!! =] NOTE: As usual, this script is completely safe as it does not require any sort of keys to function!
👍 neoxvoter, laissez-faire, statsexpert, curation.stem, gaottantacinque, gasaeightyfive, raise-me-up, marcocasario, appalachain, enforcer48, cn-neoxag, yggdrasil.laguna, flysky, kromlek, oliverschmid, nextcolony, hdmed, morwhale, steemorocco, wahedkado, zidfabour, morwhalebonus, bamomed, bensaid, akirano, safro, majjido, najmaoui, morwhalelife, morwhaletrail, steemwild, feedme, nwijoo, hachmanisabir, morwhaletip, morwhaletips, rewardsshare, agentsql, borntobe, morwhalear, steemox, zouhalsana, sarmitirajaa, raghifjamila, malihamoussa, anoirelgama, sakanijalal, hdmed.dev, kamalamezwar, theredshark, morwhaleplus, zakdour, abdoramon, atfkamal, anasjen, marofat, morwhalebox, abdohrich, makirano, morwhalelive, morwhalered, blamer, mryana, teammorocco, nadiirsafaa, rewardshare, katchoro, morwhalefr, ramanisafwan, aminamarchalik, mardibachir, elhajjasaidia, moroccoteam, najat, eternalsuccess, guiltyparties, nathanpieters, eii, likwid, fourfourfun, lightproject, dzivenu, steem.lol, zer0hedge, finprep, jrcornel, bigmoneyman, x30, minnowvotes, jschindler, abuse-signal, mmmmkkkk311, mk-pal-token, mk-photo-token, mk-sports-token, mk-marlians-tkn, mk-gg-token, mk-tunes-token, mk-natrl-token, mk-leo-token, mk-stem-token, mariuszkarowski, ilovemk311, freezepeach, tonalddrump, ticketyboo, ticketywoof, borbina, saboin, alafaqueyou, upyournose, rubberhose, hansgans, ausbitbank, wizardofaus,