Posts

First take at backing up my Hive blog (part 2)

avatar of @helcim
25
@helcim
·
·
0 views
·
2 min read

(part 1)

Unfortunately, getting the list of all posts by a user is not as simple as navigating to https://hive.blog/@helcim.json. This will give us a lot of information about a user account, but not the list of posts. It seems it will be necessary to resort to more sophisticated methods, which means reading the documentation.

The Hive API definitions may seem a bit overwhelming at first sight. So, not to waste your time, as this is not a tutorial of Hive API, head straight to the definition of the method condenser_api.get_account_history or account_history_api.get_account_history which is the same (remember the warning: "These AppBase API methods are still under development and subject to change."). This provides us with all the transactions of a specific user. This method takes three parameters:

  1. account name
  2. "start"
  3. number of transactions

Account name is obvious, "start" is somewhat mysterious to me, it turns out it is the transaction number + 10. Number of transactions is also evident, I think.

So the curl invocation will look like this:

curl -s --data '{"jsonrpc":"2.0", "method":"account_history_api.get_account_history", "params":{"account":"helcim", "start":10, "limit":10}, "id":1}' https://api.hive.blog| python -mjson.tool 

I don't care now for any transactions other than my posts. There are various types of transactions, and, somewhat misleadingly, your posts are of type "comment_operation". Needless to say, your or anybody else's comments on your posts will also be of type "comment_operation". I don't care for comments now. What would I use them for if I wanted to republish my blog somewhere else. Sure, it's good to have them, but right now I need a method to filter only my posts. So how they are different from comments? Inside the "value" block there is the "parent_author" key. If this field is empty, it means it is a post, if it contains an account name it means your "comment_operation" has a parent "comment_operation", which means it is really a comment to somebody's post. Not that difficult after all.

(part 3)

Posted Using LeoFinance Beta