The Wika Network API

Wika Network
2 min readApr 18, 2022

The easiest way to consume the Wika blockchain data

Building the foundations of the Wika Network, we have now a test net blockchain up and running, an ETL syncing the data from the blockchain to database instances, and we just delivered a MVP API to consume the data: wika_api on github.

This first version comes with 4 simple endpoints:

  • List the Urls liked by a user.
  • List the Urls owned by a user.
  • Search the Urls database using an Elastic Search query.
  • Generate recommendations for a specific user based on their likes, ownerships, network connections, and keywords.

You can find the Swagger documentation and test front-end at https://api-test.wika.network/doc/

https://api-test.wika.network/doc/

How it works

The repo is a simple MVP using Nest JS framework.

It relies on 2 data sources: Neo4j and ElasticSearch, with the schemas defined by the Wika ETL repo, responsible for syncing between the blockchain and these databases.

If you have an instance of Wika ETL up and running, you can plug this API to these databases with a read only connection, you’ll find easy to use instructions in the readme file.

For development and testing, a little snapshot of the databases is provided in the `test_db` folder, along with a docker file to get them quickly up and running.

With that, the rest is simple data access functions, defined in service classes, and a main controller class that defines and configures the endpoint.

It’s pretty cool that by adding annotations to the controller class, the NestJS framework automatically generates the documentation and front-end to test the API.

The recommendation engine

The recommendation engine generates recommendations for a specific user based on their likes, ownership, network connections, and keywords.

It performs the following algorithm:
1. get connectedUrls using `neo4j.listUrlsByNetwork(user)`: for example, if the user U1 liked a website, and the same website was liked or owned by a another user U2, all Urls connected to U2 are considered connected.
The function also orders all connected Urls by total number of likes and returns the top 100
2. The connected urls are passed to Elastic Search `More Like This` search method, returning a list of similar documents ordered by matching score.
3. Adds the total numbers of likes and the user number of likes to the search results.

This implementation is not a performant solution, but just a demo to compose a full system end-to-end, start collecting more data, and improve from there.

Coming up next

Our next step is to use all these components to deploy a cool end-user app and browser extension, stay tuned for the next update…

--

--