AskSteem API v1.1 Returns Multiple Result Sets When Query String Includes -

in #asksteem7 years ago

Hello, friends.

Please, take a look at the AskSteem API v1.1 announcement by @thekyle first: AskSteem API v1.1 Update - User Search, Includes, and Sorting.

This API is a great and valuable tool for ad-hoc queries via browser and for embedding and displaying paged results into your applications.

All kudos to @thekyle - great work!

And now to the question part of my article.

While I was trying out the types=user query type I was surprised to see that I've got multiple results in one answer.

My query was very egocentric:

https://api.asksteem.com/search?q=ervin-lemark&types=user

The answer:

{
    "time": 0.041,
    "error": false,
    "pages": {
        "current": 1, 
        "has_previous": false, 
        "has_next": false
    }, 
    "hits": 3, 
    "results": [
        {
            "following_count": 791, 
            "rep": 67.52, 
            "created": "2016-05-11T18:41:24", 
            "post_count": 5093, 
            "name": "ervin-lemark", 
            "type": "user", 
            "followers_count": 1324
        }, 
        {
            "following_count": 1, 
            "rep": 25, 
            "created": "2017-06-16T12:00:39",
            "post_count": 0,
            "name": "lemark",
            "type": "user",
            "followers_count": 5
        },
        {
            "following_count": 0,
            "rep": 25, 
            "created": "2016-04-26T07:17:33", 
            "post_count": 0, 
            "name": "ervin",
            "type": "user", 
            "followers_count": 0
        }
    ]
}

Do you see? Three hits for one query.

Entry string ervin-lemark goes into the loop three times:

  • ervin-lemark
  • lemark
  • ervin

It is interesting to see that there is a registered user with my family name @lemark. This might even be my account which I've completely forgotten about :)

There is also a user @ervin, joined in April 2016. I must research this.

I digress.

Three hits! It is definitely a feature that you have to be aware of when disseminating the results.


Check out this great API

Sort:  

Yes, this is the intended behavior of the API. In your query, you are telling the API to return all relevant users for the term "ervin-lemark" so it returns @ervin-lemark @ervin and @lemark.

If you would like it to only return results for one specific user you can use this call:
https://api.asksteem.com/search?q=name:"ervin-lemark"&types=user

Thanks a lot for your quick answer.

If I may build upon it. If I ask, for example:
https://api.asksteem.com/search?q=ervin-lemark-dan-ned-steemitblog&types=user
then I get 31 hits and ten actual result sets. Interesting algorithm :)

Thanks again. It is good to know how things are working.

Yes, you can view more by passing it the page parameter (pg=2) like so:
https://api.asksteem.com/search?q=ervin-lemark-dan-ned-steemitblog&types=user&pg=2

Congratulations @ervin-lemark! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You published 4 posts in one day

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 63493.34
ETH 2578.53
USDT 1.00
SBD 2.79