Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing get_follow_count #10

Open
therealwolf42 opened this issue Nov 5, 2017 · 3 comments
Open

Missing get_follow_count #10

therealwolf42 opened this issue Nov 5, 2017 · 3 comments

Comments

@therealwolf42
Copy link
Contributor

SteemJS has the function steem.api.getFollowCount which is missing with dsteem.

I've tried client.database.call('get_follow_count', [ name ] ) but get the following error:

Main Error itr != _by_name.end(): no method with name 'get_follow_count

Would be amazing if you could fix this or tell me if I made a mistake :)

@jnordberg
Copy link
Owner

That's because get_follow_count is in a separate api plugin in steemd called follow_api. I want to add a strongly typed helper for this but not sure yet how best to go about it, a lot of calls will change with steemd's new appbase api so I don't want to refactor just yet. For now you can use this:

const response = await client.call('follow_api', 'get_follow_count', ['username'])

@CryptoSharon
Copy link

CryptoSharon commented Feb 2, 2018

client.call('follow_api', 'get_following', ['sweetsssj']).then(console.log)
(node:4249) UnhandledPromiseRejectionWarning: RPCError: a0 != e: too few arguments passed to method
    at Client.<anonymous> (/home/sharon/projects/node/bubot/node_modules/dsteem/lib/client.js:162:23)

edit:

Tried again, this is the code that worked:

client.call('follow_api', 'get_following', ['sweetsssj', '', 'blog', 100])

I tried using 1000 (like the Steemit website does in its ajax post call) but I got RPCError: limit <= 100:

edit2:

There seems to be no pagination, so I can only get the first 100 followers of any account unless I scrape it out of Steemit... I did not realize that when I made this:

const get100 = accountName =>
  client.call('follow_api', 'get_following', [accountName, '', 'blog', 100])

const getAllFollowing = (accountName, accumulator) =>
  !accumulator || accumulator.length % 100 === 0
    ? get100(accountName, accumulator).then(r =>
      getAllFollowing(accountName, accumulator ? accumulator.concat(r) : r))
    : Promise.resolve(accumulator)

getAllFollowing('sweetsssj').then(console.log)

Now I have an array of the first 100 followers over and over...

@jnordberg
Copy link
Owner

Many steemd api's are paged by partial string matching, so passing f starts indexing from e.g. faaaa etc so use the last name you got as the starting for the next page and initial page being an empty string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants