Making sense of the Steem API discussion payload just keeps on getting easier!
Welcome back to part two of @steemsmarter Steem API Basics. Today we will be looking at the content, author, tag, and metadata information we can extract from the discussion payload pulled from the Steem API.
Where we left off
In my previous post I explained how we can use Ruby and my SteemPostFinder class to pull down the JSON payload for a specific post or comment. If you haven't read it already, it's a good idea to do so. It's pretty epic.
Playing with the payload again
I'll whip the payload out again for reference, but for today we're only going to be playing with the tip.
{
"id": 33672515,
"author": "thescubageek",
"permlink": "steemsmarter-finding-daily-posts-with-ruby",
"category": "steem",
"parent_author": "",
"parent_permlink": "steem",
"title": "SteemSmarter: Finding Daily Posts with Ruby",
"body": "Steem is awesome. The Steem API documentation, however, is definitely not. I want to help change that.",
"json_metadata": {
"tags": [ "steem", "steemdev", "ruby", "blockchain", "steemit" ],
"users": ["steemsmarter"],
"image": [
"https://ws1.sinaimg.cn/large/006tNc79gy1folmvqw02ej30m80ek773.jpg",
"https://ws2.sinaimg.cn/large/006tNc79gy1folmvpf65lj30m80bfq4j.jpg"
],
"links": [
"https://steemit.com/@ashe-oro",
"https://steemit.com/@crypthoe",
"https://steemit.com/@steemsmarter",
"https://steemit.com",
"https://github.com/inertia186/radiator",
"https://steemit.com/@inertia"
],
"app": "steemit/0.1",
"format": "markdown"
},
"last_update": "2018-02-19T04:36:15",
"created": "2018-02-19T04:30:03",
"active": "2018-02-22T01:01:24",
"url": "/steem/@thescubageek/steemsmarter-finding-daily-posts-with-ruby",
"root_title": "SteemSmarter: Finding Daily Posts with Ruby",
"author_reputation": "92507853048",
/****....... a bunch of other stuff we'll talk about later .........****/
}
Discussion Content
The following fields contain the basic meat of a post or comment itself -- who wrote it, what tags it has, where to find it via url, and the actual content.
id
- integer
Discussion id on the blockchain. This useful for looking up the top-level post in a nested comment.author
- string
Account name of the discussion author.permlink
- string
The url permlink to the discussions (hyphanized title); see my previous post to learn more about how permlinks work.title
- string
The full title for the post.body
- string
The full body of the post in Markdown format. I use the RedCarpet gem to translate the markdown in this field into the fully rendered post in Ruby.category
- string
The top tag under which this post is filed. This affects which tag the post appears under when ranked by Steem's trending mechanism.url
- string
URL path (sans domain) to the discussion. This constructed for us automatically as"#{category}/@#{author}/#{permlink}"
root_title
- string
The discussion is a post, then this is the same astitle
. If the discussion is a comment, then this is the same as the title of the "root" post, aka the top-level post parent in the comment hierarchy.author_reputation
- string (large integer)
The author's reputation stored as a string but representing a very large integer (use.to_i
in Ruby to convert it). You'll notice that this number does not match to the two-digit reputations shown on Steemit. In an upcoming post, I'll share the secret sauce for how you caculate the Steemit reputation scores from theauthor_reputation
integer.
JSON Metadata
The json_metadata
for a discussion varies depending on the originating platform, the format of the data (dTube video vs standard post, for example), and other factors.
For content created on Steemit, the json_metadata
for a post looks like:
"json_metadata": {
"tags": [ "steem", "steemdev", "ruby", "blockchain", "steemit" ],
"users": ["steemsmarter"],
"image": [
"https://ws1.sinaimg.cn/large/006tNc79gy1folmvqw02ej30m80ek773.jpg",
"https://ws2.sinaimg.cn/large/006tNc79gy1folmvpf65lj30m80bfq4j.jpg"
],
"links": [
"https://steemit.com/@ashe-oro",
"https://steemit.com/@crypthoe",
"https://steemit.com/@steemsmarter",
"https://steemit.com",
"https://github.com/inertia186/radiator",
"https://steemit.com/@inertia"
],
"app": "steemit/0.1",
"format": "markdown"
}
tags
- array of strings
The top five tags for a post; the first tag value is always the same as thecategory
valueusers
- array of strings
List of direct references to user(s) via@
in the dicussion bodyimage
- array of strings
List of image urls used in the discussion body; the first image is always set to the thumbnail on Steemitlinks
- array of strings
List of links used in the discussion bodyapp
- string
App used to generate the discussionformat
- string
Format of body content (typicallymarkdown
)
Discussions created on other platforms or extensions may contain different json_metadata
. The json_metadata
can even be an empty hash! Therefore, it's important to use defensive coding practices when working with this field.
Timestamps
These keep track of time-related events. Duh.
last_update
- datetime
Timestamp of the last time the author edited the discussioncreated
- datetime
Timestamp of when the discussion was createdactive
- datetime
Timestamp of last interaction (edit / vote / comment) for the discussion
What's Next?
Voting! In my next post we'll investigate how to retrieve detailed information about who voted, how much the weight they voted with, their reputation, their voting power, and more.
Thanks for reading, and if you have any questions please ask away in the comments section. If you enjoy this, please resteem and upvote, and remember to follow @thescubageek and @steemsmarter to stay on top of our latest Steem projects.
Until next time, keep on Steemin' Steemians!
Your article is great and can help a lot of people.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks, I appreciate it! I look forward to getting me new post about votes out really soon!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
hell yeah! U are crushing it @thescubageek! The Steem community will benefit for a long time because of the time you put in to learning this and even better...taking the time to clearly explain it to us and lock it in to the Steem blockchain forever.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit