delion.io API to simply connect to the IOTA Tangle

The technology behind IOTA can be intimidating to beginners but also experienced developers when trying to develop own applications based on IOTA Tangle. Its architecture requires a deep-dive into trits, trytes, proof-of-work, fullnodes etc. to participate in the distributed ledger called Tangle.

However, its superior attributes over Blockchain like fee-less transactions and scalability are too good to stay away from launching own projects based on IOTA Tangle.

The best way to get a project done faster is to start sooner (Jim Highsmith)

This tutorial is a quick and simple guide on how to connect your application to the Tangle via the API from delion.io in under 9 minutes (fun fact: The number 9 in IOTA is mapped to zero).

Prerequisites

Basic knowledge of working with REST API + JSON

Basic understanding of HTML + JavaScript + CSS

Account on delion.io

Get familiar with the delion.io developer docs

Goals

We are going to connect an existing standalone simple web application to the IOTA Tangle via delion API. The focus is on showing the big picture rather than diving into the application source code.

The purpose of the demo application is to offer document and text translation by using translation services APIs from Google, Amazon Web Services and DeepL. The web application is a demo use case based on a concept which we call API Splitting.

The goal of this tutorial is to show how to split any premium API Service into small chunks, so that only the volume actually consumed is billed — without sacrificing on good quality of a paid service. Curious on how that works? Great, let’s go ahead!

Quick overview

We firstly introduced our new concept called API-Splitting on an IOTA Developer Meetup in Berlin on April 10th, 2019. API Splitting is meant to split any suitable API service into small chunks, so that only the actual API consumption is paid for.

For this purpose we chose to apply this concept on premium translation API services like DeepL. DeepL is a german-based company with the best machine translation available, powered by a world-leading neural network technology.

Problem

Although there is a free version of DeepL online which allows to translate a single document, it comes with a restriction. The translated document is watermarked and can not be edited. To remove the watermark and receive an editable document an upgrade to DeepL Pro is necessary. We believe that’s fair — good quality comes at a price.

The Starter Pro Package is priced at 8.99 Euro per month on a monthly subscription, giving a contingent of 5 documents. Imagine there are people out there just want to translate two documents in a very high quality. The price would be € 4.50 / document.

Even worse: Translating 6 documents requires the Advanced Pro Package priced at 29.99 Euro with a contingent of 20 documents, resulting in roundabout 5 Euro / document instead of € 1,50 / document.

The above mentioned inefficiencies apply to services, which charge a fixed price for a fixed contingent.

Needless to say that this pricing models cause deadweight losses on both the service provider for not realizing potential sales and the customer who steps back from using the service due to relatively high costs.

The solution is to introduce Pay-Per-X (from a customers’ viewpoint) or Get-Paid-Per-X (from a merchant’s point of view), whereas X refers to any divisible unit of a service.

Solution

This is where IOTA with its capability to process microtransactions in combination with delion comes into place to create value to suppliers and consumers. In the above mentioned case the supplier of a service does not need to introduce a new micropayment channel (which does not really exist) or change any of the existing billing methods. On the other hand, interested consumers/customers can make use of the service without depositing any credit at the provider. Furthermore, no confidential data like personal data or credit card details have to be revealed to the service provider, giving an extra protection of data privacy.

It is all realized with an application from a reseller that buys larger quantities from service providers and resell in smaller chunks to customers. This concept opens up new markets, creating win-win-win situations for suppliers, resellers and the customers.

As this human-centric demo application is fully paid in IOTA, no personal data nor credit card details are necessary.

Architecture

Customer experience first: Potential customers of such an application need to have a really simple and straightforward approach to pay for the service. We achieve this by allowing the customer to trigger microtransactions by just using a username and password, like any other comfortable payment method out there.

On the other hand, we have the app developers who can connect their applications to the IOTA Tangle within a very short time using delion. The acceptance of the application is increased by the fact that the customer can simply authenticate and pay.

delion.io architecture overview

How it works

Following is a brief top level sequence diagramm on how the demo translation application works beginning from user/machine interaction over application to delion, Tangle and finally API.

After uploading a document to the application by the user/machine, the application creates a payment object containing the price for the respective document. The application shows an order summary with the price for using the service to translate the document. If the user accepts the offer, a click on “buy” opens up a new delionPay frame provided directly by delion, asking for authentication.

After successful authentication, the user is shown a confirmation summary to approve the transaction.

Once the transaction is approved, the translation app provider can check the status of the transaction by calling https://api.delion.io/payments/v1/payment/{payid}, providing the payment-ID which was generated the first time after a document was uploaded.

If the customer have had enough balance, the transaction status will be successful and the translation app provider has the guarantee that the payment went through.

Next the application transfers the document to the translation API and returns the translated document to the customer.

Important to note: delion.io eventually executes this transaction asynchronously on the IOTA Tangle. This brings the crucial advantage, that the transaction takes place instantaneous regardless of Tangle confirmation times, which can take up to several minutes to be confirmed.

Conclusion

We just showed how we can transform any suitable API service into a Pay-Per-X model by just making two API calls to delion.io to integrate your application with IOTA Tangle.

First API Call is necessary to create a new payment object and the second is to check if the payment went through. The rest of the application logic remains unchanged.

Great, it’s all done!

Basically this sequence diagram can be applied to manifold applications. Just replace Translation API with an API service of your choice.

Now you’re set to run your application on the IOTA Tangle using the API of delion.io

If you encounter any problems when using delion API, feel free to get in touch with one of our developers on our Discord channel. We’re happy to help you get started with your own application ideas.

What’s next?

Now given an overview of how delion works in between an application and IOTA Tangle, we will upload the source files for this demo application in near future.

I’m a Pro. How do I get started?

First of all, if you don’t have a delion account already, you can sign up for free at the delion management console. (This takes just 1 minute).

The delion account is mandatory to interact with the IOTA Tangle.

Next, head to our delion.io developer docs, where you will find all the information on how to interact with the IOTA Tangle.

I want to stay up to date.

To be the first being notified about new use cases or new delion.io features, be sure to subscribe to our newsletter on our website https://delion.io. As a subscriber, you will be among the first to receive a notification when we upload the source files for this demo application.

We are active on Twitter, too. Happy to welcome you there as follower!

Thanks for reading!