ultimate-connectivity-for-immudb-with-immugw


Ultimate connectivity for immudb with immugw

API’s play a crucial role to overcome the frontiers of niche programming languages and heterogeneous information systems. Luckily there is one protocol almost every system understands: HTTP. The SDKs, immuclient, and immuadmin are communicating over gRPC and mTLS Authentication directly with immudb. Immugw is a middleware that translates REST calls into gRPC for you. This way immudb can be used anywhere.

key gRPC HTTP-API
Protocol HTTP/2 HTTP
Payload Protobuf(small,binary) JSON (readable, huge)
Specification strict every HTTP
Performance very fast and efficient decent (7 – 10 times slower)
Performance TLS TLS

REST APIs are widely used and popular APIs for app integrations, microservice integrations, and web services.
If the goal is to build an internal or open system that exposes immudb as a resource to other parties, immugw is the right tool to use.
REST is good enough for most use cases, universally supported, and easy to use.

REST-Calls with immudb, fast and easy

Our hard-working gophers always do their best to help you get things done without a headache. Immugw is well documented and there is a swagger file for reference. However, sometimes things can’t be fast enough. The open-source project curl-converter is converting requests with curl syntax into to Python, Ansible URI, MATLAB, Node.js, R, PHP, Strest, Go, Dart, JSON, Elixir, and Rust. Startup immudb and immugw in seconds to try your first API Call. Loop up the curl examples from the immugw docs. First, we are going to log in.

curl --location --request POST 'http://immugw:3323/v1/immurestproxy/login' 
--header 'Content-Type: application/json' 
--data-raw '{
    "user": "'$(echo -n immudb | base64)'",
    "password": "'$(echo -n TWdn4TK0ACq8amSeYBW!9E9h3S0am?G! | base64)'"
    }
}'

Paste the curl command into the converter and select the output language. For this blog, we are selecting Python.
Now the converter is giving us the Python code sniped and it is almost perfect. We just have to do the base64 conversion by our selves.

Add the correct IP of your immugw instance to the code as well as the user and password. Login credentials should never be passed in plaintext that’s why it is important to encode them. This can be easily done with a base64 encoder. By calling the login API with the correct credentials it will respond with a valid token. We will have to use that token for further requests.

headers = {
'Content-Type': 'application/json',
}
user = base64.b64encode("immudb".encode("utf-8"))
password = base64.b64encode("immudb".encode("utf-8"))

url = 'http://127.0.0.1:3323/v1/immurestproxy/login'
data = '{ "user": "'+str(user, "utf-8")+'", "password": "'+str(password, "utf-8")+'"}'
response = requests.post(url, headers=headers, data=data)
#variable will be used in follow up calls providing the token json_response["token"]
json_response = response.json()
print(response.json())

The API will response with codes. It is important to understand what they mean.
Response code 200 is signaling that the request was successful.
Code 403 "forbidden" is saying that there are missing some authorizations.
*The codes 500 stands for internal server error and 503 is saying that the service is unavailable.

There are existing many more response codes that can be found on wikipedia.

Our call should be responded by code 200 and with a token. The token can be displayed by printing "response.json()".
Having that token enables us to do follow up calls.

switching database

With immudb it is possible to create and use many databases. If you don’t want to use an additional database other than the standard one, please skip this step. I created a database called "restapiblog" for this blog. We have to switch to that database to use it. This can be done with an API-call too. Things get more interesting now because every follow-up call using this database must use the new token, that came with the switch.

headers = {
    'Content-Type': 'application/json',
    #token that came with the login response
    'Authorization': json_response["token"],
}
response = requests.get('http://127.0.0.1:3323/v1/immurestproxy/usedatabase/restapiblog', headers=headers)
print(response.json())
json_response = response.json()
#the token must be used for every call using database restapiblog
new_token=json_response["token"]

add item and get item

Time to add some key-values. This is again from our curl-examples.
Adding the client "client:Ms. Noelia Jaskolski" and the value "Visa 1514284849020756 09/21" to immudb.
For this call, it is important to have the token from the login or the usedatabase call.
If successful, this call will respond with the index of the item.

key = base64.b64encode("client:Ms. Noelia Jaskolski".encode("utf-8"))
value = base64.b64encode("Visa 1514284849020756 09/21".encode("utf-8"))

headers = {
    'Content-Type': 'application/json',
    'Authorization': json_response["token"],
}

data = '{"key": "'+str(key, "utf-8")+'", "value": "'+str(value, "utf-8")+'"}'
print(data)
response = requests.post('http://127.0.0.1:3323/v1/immurestproxy/item', headers=headers, data=data)
json_response=response.json()
print(response.json())

Use the index returned by the last call or any index you are interested in.

response = requests.get('http://127.0.0.1:3323/v1/immurestproxy/item/index/'+str(json_response["index"]), headers=headers)

The goal of this blog was to show you how to use immudb with a REST-API provided by immugw.
It enables you to translate curl statements into many programming languages and use most functionalities of immudb with API-calls.
immudb is extremely flexible and running on most kinds of hardware and operating systems.
Sometimes there are restrictions or very niche systems that cannot run immudb, the API of immugw provides a simple workaround for that.
It gives you the flexibility, portability and independence needed in modern service architectures.

Get immutability for your services now!

immudb

BUILT ON THE FASTEST
IMMUTABLE LEDGER
TECHNOLOGY

Open Source and easy to use in new applications and easy to integrate into existing application.

Subscribe to Our Newsletter

Get the latest product updates, company news, and special offers delivered right to your inbox.

Subscribe to our newsletter

Use Case - Tamper-resistant Clinical Trials

Goal:

Blockchain PoCs were unsuccessful due to complexity and lack of developers.

Still the goal of data immutability as well as client verification is a crucial. Furthermore, the system needs to be easy to use and operate (allowing backup, maintenance windows aso.).

Implementation:

immudb is running in different datacenters across the globe. All clinical trial information is stored in immudb either as transactions or the pdf documents as a whole.

Having that single source of truth with versioned, timestamped, and cryptographically verifiable records, enables a whole new way of transparency and trust.

Use Case - Finance

Goal:

Store the source data, the decision and the rule base for financial support from governments timestamped, verifiable.

A very important functionality is the ability to compare the historic decision (based on the past rulebase) with the rulebase at a different date. Fully cryptographic verifiable Time Travel queries are required to be able to achieve that comparison.

Implementation:

While the source data, rulebase and the documented decision are stored in verifiable Blobs in immudb, the transaction is stored using the relational layer of immudb.

That allows the use of immudb’s time travel capabilities to retrieve verified historic data and recalculate with the most recent rulebase.

Use Case - eCommerce and NFT marketplace

Goal:

No matter if it’s an eCommerce platform or NFT marketplace, the goals are similar:

  • High amount of transactions (potentially millions a second)
  • Ability to read and write multiple records within one transaction
  • prevent overwrite or updates on transactions
  • comply with regulations (PCI, GDPR, …)


Implementation:

immudb is typically scaled out using Hyperscaler (i. e. AWS, Google Cloud, Microsoft Azure) distributed across the Globe. Auditors are also distributed to track the verification proof over time. Additionally, the shop or marketplace applications store immudb cryptographic state information. That high level of integrity and tamper-evidence while maintaining a very high transaction speed is key for companies to chose immudb.

Use Case - IoT Sensor Data

Goal:

IoT sensor data received by devices collecting environment data needs to be stored locally in a cryptographically verifiable manner until the data is transferred to a central datacenter. The data integrity needs to be verifiable at any given point in time and while in transit.

Implementation:

immudb runs embedded on the IoT device itself and is consistently audited by external probes. The data transfer to audit is minimal and works even with minimum bandwidth and unreliable connections.

Whenever the IoT devices are connected to a high bandwidth, the data transfer happens to a data center (large immudb deployment) and the source and destination date integrity is fully verified.

Use Case - DevOps Evidence

Goal:

CI/CD and application build logs need to be stored auditable and tamper-evident.
A very high Performance is required as the system should not slow down any build process.
Scalability is key as billions of artifacts are expected within the next years.
Next to a possibility of integrity validation, data needs to be retrievable by pipeline job id or digital asset checksum.

Implementation:

As part of the CI/CD audit functionality, data is stored within immudb using the Key/Value functionality. Key is either the CI/CD job id (i. e. Jenkins or GitLab) or the checksum of the resulting build or container image.

White Paper — Registration

We will also send you the research paper
via email.

CodeNotary — Webinar

White Paper — Registration

Please let us know where we can send the whitepaper on CodeNotary Trusted Software Supply Chain. 

Become a partner

Start Your Trial

Please enter contact information to receive an email with the virtual appliance download instructions.

Start Free Trial

Please enter contact information to receive an email with the free trial details.