Building a Ðecentralized API on Computes!
Computes is more than a decentralized mesh computing platform. Many of our beta developers are calling it a decentralized operating system.
We’ve already demonstrated how to host static web sites via IPFS using a new “.a” TLD via our Arpadyne decentralized DNS demo. We’ve also demonstrated how to build a decentralized web app allowing a web browser to submit compute operations directly into Lattice and receive realtime browser notifications via IPFS pubsub on compute results. Today, we would like to demonstrate how to build a decentralized API or long running service or oracle on top of the Computes platform!
APIs have proven to be vital building blocks for centralized applications. Good news, with a little tweaking, you can now expose them to the new world of decentralized apps (ÐApps) running on Computes!
Rather than calling your existing REST API from a centralized URI, we will need to modify the request and response to run over IPFS pubsub. We handle this easily for you in the Computes platform. For the purpose of this example, we’re going to send text from a form’s textarea field into a decentralized sentiment analysis algorithm running on the Computes decentralized public network.
Your new decentralized API receives a realtime IPFS pubsub message of an incoming request (“computes_sentiment_analyzer”) which looks something like:
{"q":"I love skynet", "task_hash": "z..."}
The API then submits this compute request to Lattice. Meanwhile, the browser is subscribed to the task_hash channel of the IPFS pubsub waiting for the response. The API transaction flow is captured below:
Keep in mind that your APIs no longer need to run in web servers or cloud infrastructures — it’s decentralized ;)
Here’s our example’s GitHub repository. Here’s a brief video of this demo in action!
Learn more about the Computes vision. Learn more about the Computes architecture. Join our beta program and start mesh computing today!
Stay tuned to this blog for more exciting information about our new technology stack and development progress! You can also reach us on Twitter, Facebook, and GitHub.