Introducing a public autocomplete API for steem usernames

steem.rocks landing page includes a simple input which you can enter your username to that field and continue using the site.

Almost all 3rd party steem related websites ask for usernames at some point. I wanted to add an auto-complete feature here, so users can type a few characters and select their username.


Auto complete feature on Steemit wallet

Instead of doing that as a steem.rocks centered feature, I developed a public API which every 3rd party developer can use and benefit.

How it works?

  1. It indexes all usernames in the Steem chain by using the lookup_accounts call.

  2. Then it stores all usernames in the redis with sorted sets to get auto-complete functionality. (Thanks to beautiful walrus library)

Using it as a client

Just pass ?username to that address:

http://autocomplete.steem.rocks/?username=utopia


Autocomplete options for utopia

Running on your own

You can run your own autocomplete API instance.

Installation

$ git https://github.com/emre/steem-username-autocomplete-api.git
$ cd steem-username-autocomplete-api
$ virtualenv -p python3.6 autocomplete-api-env
$ source autocomplete-api-env/bin/activate
$ pip install -r requirements.txt
Indexing the database
$ FLASK_APP=autocomplete_api/app.py flask initdb

Note: Indexing all steem usernames takes 10 minutes on my development setup.

Serving the api
$ FLASK_APP=autocomplete_api/app.py flask run

Feel free to test, debug, break it. Just let me know after that. :)

Github Repository: @emre/steem-username-autocomplete-api



Posted on Utopian.io - Rewarding Open Source Contributors

H2
H3
H4
3 columns
2 columns
1 column
15 Comments