AskSteem API v1.1 Update - User Search, Includes, and Sorting

in #asksteem7 years ago (edited)

Hello, everyone!
Today I'm releasing the AskSteem API v1.1 which brings tons of new features for developers to play with in their apps.

What is AskSteem

AskSteem is a powerful and fast search engine that indexes the steem blockchain. You can find out what AskSteem is capable of here

What is the AskSteem API

The AskSteem API is a RESTful HTTP API that allows developers to integrate search functionality into their applications easily. To learn more about the AskSteem API v1.0 read this post.

Whats New

The AskSteem API v1.1 brings loads of new functionality that has been requested by developers.

Includes

You can now tell AskSteem to return specific fields for each search result so you don't have you query the blockchain yourself for additional data. By default the AskSteem API returns title,summary,net_votes,children,permlink,created, and tags fields for each result. However, you can now use the include URL parameter to include specific fields that are not returned by default.

For example, to include the json_metadata field for each result use the following:
https://api.asksteem.com/search?q=asksteem&include=meta
This will return results that look like this:

{
        "children": 89,
        "type": "post",
        "permlink": "introducing-asksteem-a-steem-search-engine",
        "meta": {
            "format": "markdown",
            "app": "steemit/0.1"
        },
        "tags": ["steemit", "steem", "asksteem", "steem-project", "steemdev"],
        "author": "thekyle",
        "summary": "\nHello, Steemians!\nOver the past month, I've been building a new search engine that indexes the steem blockchain. It's currently live at asksteem.com. The goal of AskSteem is to provide a reliable, powerful, and fast search engine that is optimized for steem. In this post, I'd like to cover some of the features that are available. \nQuery Syntax\nThere are many different ways that you can query the AskSteem index. I've created a video demonstrating each of them, but you may also read their descrip",
        "net_votes": 300,
        "created": "2017-06-03T19:07:45",
        "title": "Introducing AskSteem - A steem search engine"
    }

The include parameter can take only one value or multiple values seperated by commas.

User Search

When the AskSteem API originally launched it only supported searching posts on the blockchain, not users like from the regular AskSteem.com interface. But with v1.1 developers can now tap into our user database with the types URL parameter.

To include users and posts in search results use the following:
https://api.asksteem.com/search?q=steem&types=post,user
or for only users:
https://api.asksteem.com/search?q=steem&types=user
The results would look like:

{
        "followers_count": 226,
        "name": "steem",
        "rep": 25,
        "created": "2016-03-24T17:00:18",
        "post_count": 0,
        "type": "user",
        "following_count": 0
}

User results also support the includes parameter for fetching additional fields about users.

Sorting

This new version of the API supports custom sorting of results by a field with two new URL parameters sort_by and order. The sort_by parameter takes the name of the field you would like to use for sorting, for example, created (for creation date) or net_votes (for the number of votes). The order parameter determines how the field is to be sorted and accepts either desc or ascfor descending and ascending respectively.

For example to sort results by most recent use the following:
https://api.asksteem.com/search?q=steem&sort_by=created&order=desc
To sort results by most comments use this:
https://api.asksteem.com/search?q=steem&sort_by=children&order=desc
The default value of order is desc so it can be left out like below:
https://api.asksteem.com/search?q=steem&sort_by=net_votes

Restrict Search Results to App

While this is not a new feature of the API and was available in v1.0 and the standard AskSteem.com interface it was not documented. To restrict search results to a specific app use the following query syntax:
meta.app:appname AND query goes here

How to Upgrade

If you used the AskSteem API v1.0 in your app then you have already been transitioned to using this new version. The AskSteem API v1.1 is fully backward-compatible with v1.0.

Summary

Here is a table to summarize the parameters of the API.

paramdescriptiondefault
qtakes the search term to query for.None
pgtakes the page number1
includetakes a CSV list of additional fields to returnNone
typestakes a CSV list of types of items to return (post/user)post
sort_bytakes a single field to be used for sorting the results_score
ordertakes either desc or ascdesc

Required Attribution

We require that all applications using the API place AskSteem branding on the search results page in a location that is immediately visible to the user without any interaction on their part. Additionally, to ensure reliability and uptime we request that you send between 1% and 2% of post beneficiary rewards to the @hoxly user account if applicable to your app.

Branding Examples:

Here is an example of some HTML code to embed AskSteem branding:
<a href="https://www.asksteem.com"><img src="https://cdn.hoxly.com/asksteem/attribution.png" width="100px"></a>

Preview:

Thank you, and happy searching!

Sort:  

Great stuff!! thanks for serving the community and adding these new features!

I'm not very good at codes but It's still very interesting. Is there app that we can download so I can use steemit on my android mobile phone?

Hai akilie1029 I'm new to steemit can you please follow me

this is great. i must try this one. it seems like user friendly. anyway

WOW ! Really a great initiation. Appreciated...

Great API! I am a developer I found it very useful! I will use it! thanks for the info!

Great! Send me the link to whatever you build with it. :)

mmhmm

Let me guess. Your're thinking right????

Adrian M you are incredible. I am not a programmer or coder, but I appreciate what you are doing enormously! Thank you. You and other coders produce valuable tools we can use.

I wanted to thank you here for the work you've done with DTube. I love it! You are off to a great start. I did a video on DTube recently and posted it here on Steemit. You'll notice that you figure prominently in it.

I loved the interview you did with my friend Dan Dicks of Press For Truth. Would you be open to an interview with me so I could spread your message on what you've done with DTube?

Here is the link to the video I did so you can see it.

https://steemit.com/dtube/@terrybrock/n1108mgs

Thank you for what you are doing to help us. Keep up the good work!

Terry

Hi Terry,
Thank you for your kind words, however, I believe you meant this message to be for a friend of mine @heimindanger (Adrian M), not me. That said I am the lead developer behind AskSteem, so if you have any questions regarding that project do let me know.

Yes, my mistake, thekyle. Thank you for your help.

Love your API and plan on using it on a future project.

Can't wait to see what you do with it! :)

WOW! You set a high bar with this one !!

Glad to see this going so well!

Thanks. :)

Wow, this sounds really cool! Question, I noticed you earn a lot per post. I currently have been getting $0.02 per post lol! Would I earn more if I had more Steem Power?

Steem power determines how much your individual vote is worth (mine is worth about 5 Steem Cents right now). While there are some accounts that have upvotes worth hundreds of dollars those are rare. If you want to make more money I'd recommend to just keep producing quality content that people want to read. :D

Wow, thanks a lot for replying, man! I really appreciate it!