Make a REST API To Track Products

Yehia Tarek
Oct 24, 2019 · 4 min read

In this article, I make a simple REST API for tracking products using IOTA. This Tracking API will be used by products owner to record their products and all data they need about it(location, owner, modifications, time) then the API will push data to tangle than the API will respond with the root address to track all products and array of addresses for each product. This array of addresses should be printed as QR code on each product for QR-code reader to update/read data. For the tangled part, I used MAM restricted for communication and generate rout and addresses using it. You can found what I do in detail here.

The Sequence Diagram of the REST API:

API endpoints, Calls, controller and response

Creating Products Post Call

The client needs to send all his products information like id, date, details…etc on JSON array:

It will look like this on Postman



The IOTA module. all IOTA modules are included form this article.

Then the response will be a JSON object with the root address on MAM Merkel tree, Could be used in GET call to fetch all product data and Array of addresses for each product.


Now using all these addresses you can get data by ‘GET’ call.

Get Products Info GET Call

The client sends the address of a group of products he wants to keep track of.




IOTA Module

Response products info and all new products added or changes happened after that:

Update Call

This call will be made by the IoT devices assume some products transferred to another country or got some modification whatever.

I used post call as I can’t update data already deployed on Tangle


Body(body could be any form of data the user want to send):



IOTA Module:


It’s the new address has been generated client could user could get it from previous addresses he has.

Test it using GET call

And it will give response:

To make sure everything works as expected. I will use the GET call with the root address and see if the update has been added to the Merkel tree or not.



The updates pushed by the IoT devices had been added!

What to do next?

1-Need to get user public address on POST calls to be more personalized for each user.

2-Need to send MAM restricted password when products had been created then add this password to IOT devices for updates.

But all these updates are simple and I didn’t add them to focus on the main problem.

Practically, All the API calls will return some unorganized data so I could add a filter module by time. As the Merkel tree changed by time ex:

address1→ for all changes from 20/1/2019 till now.

address2→ for all changes from 30/11/2019 till now.


After the time filter, I need to add ID filters to get all changes happened to a specific product or range of products. To be more organized and help the developer with no experience in tangle interact with it. It would be awesome if I found a way to organize all addresses so for address X give me all changes that happened to product X using tangle without the need for any filters. If you have any better solution or feedback please leave a comment. Thanks.

Project source code

Get Best Software Deals Directly In Your Inbox


Coinmonks is a non-profit Crypto educational publication.

Sign up for Coinmonks

By Coinmonks

A newsletter that brings you week's best crypto and blockchain stories and trending news directly in your inbox, by Take a look.

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.


Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project —

Yehia Tarek

Written by

A Full-Stack Blockchain Developer,


Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project —

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store