Pulling wallet (and other) profile data from steemit.com/@username.json using javascript
steemdev·@justinw·
0.000 HBDPulling wallet (and other) profile data from steemit.com/@username.json using javascript
 Did you know that steemit.com's front-end (condenser) serves profile data for use in other applications via JSON? Check it out, example: [steemit.com/@username.json](https://steemit.com/@username.json). Just fill in your username and go. SBD, STEEM, and VESTS balances are available in addition to quite a bit more. steemit.com serves content in gzip compressed format, so you do need to load a library and pipe it in order to get valid JSON - easy enough. I'm sure some of you will find this useful :) This is an example and it just displays a few objects, but it's as simple as this: ``` const https = require('https'); const zlib = require('zlib'); let options = { host: 'steemit.com', path: '/@username.json' }; https.get(options, function (res) { let json = ''; let gunzip = zlib.createGunzip(); res.pipe(gunzip); gunzip.on('data', function (chunk) { json += chunk; }); gunzip.on('end', function () { if (res.statusCode === 200) { try { let data = JSON.parse(json); console.log('STEEM balance: ' + data.user.balance); console.log('SBD balance: ' + data.user.sbd_balance); console.log('VEST balance: ' + data.user.vesting_shares); } catch (e) { console.log('Error parsing JSON'); } } else { console.log('Non-200 status code received: ' + res.statusCode); } }).on('error', function (err) { console.log('Error pulling JSON: ' + err); }); }); ``` Enjoy and Steem On!
👍 justinw, sasagood, oroger, bindia, dikkyamiputra, dragosroua, raluca, roomservice, playfulfoodie, ausbitbank, krystle, tarazkp, awesomianist, aismor, zygimantas, fyrstikken, vikx, cryptos, slorunner, infobot, gtg, trafalgar, leomichael, igster, bosjaya, crystalandbones, adnanrahic, furion, transisto, newsflash, julianita, recrypto, waphilip, andrew5602, gdenocewelch, contenidos, fode, revdocwelch, gaildenocewelch, mimulusamsterdam, anddres,