[UPCOMING WEBINARS] Save on Development Costs and Open Up Your IBM i via APIs. REGISTER NOW
[UPCOMING WEBINARS] Save on Development Costs and Open Up Your IBM i via APIs. REGISTER NOW.
Home ยป App Development ยป Mobile Application Development ยป Progressive Web Apps ยป Integrate PWAs With Powerful Business Process And Artificial Intelligence REST APIs

Integrate PWAs With Powerful Business Process And Artificial Intelligence REST APIs

By LANSA Editors
Published On June 8, 2021

Build Robust Applications 3x Faster

Keep the light on.

Join our mailing list for development guides and solutions for constant IT innovation.


Integrating Business Processes and Artificial Intelligence with REST APIs will benefit businesses by shortening development time and increasing output. Bringing artificial intelligence, machine learning, and deep learning capabilities into your Visual LANSA apps via REST APIs can really put you one step ahead of the competition. Google Cloud Vision and Google Natural Language REST APIs are two examples of AI functionality you can add to your Visual LANSA apps to turbocharge your capabilities. In this article you will find out more about what REST APIs are, how to use them from within LANSA, and two LANSA capabilities (Code Generator and the Routing Framework) that work closely with APIs. Finally, you will see how Visual LANSA can deploy your final application as a progressive web app. Utilizing REST APIs can make it easy to do legacy application modernization.

What is Visual LANSA REST API?

RESTful API โ€“ or RESTful web service โ€“ is a Representational State Transfer (REST)-based application program interface that uses HTTP requests to GET, PUT, POST, and DELETE data. REST APIs, regardless of protocol, are popular among developers due to their versatility and the fact that they do not require the installation of additional applications or libraries.

Let’s look at how your company can use APIs as leverage in this article about IBM AI API.

What are the API Definitions in Visual LANSA?

REST API definitions are set up in a server module. The API configuration is automatically published and updated when the server module is compiled.

The server module API definition consists of:

Definition Publish as Swagger V2 and/or OpenAPI 3
Info Title, Description, Terms of Service
Security Requirements HTTP basic, API Key, OAuth2, OpenIDConnect
Paths URLs that map to operations with parameters.

Each operation is mapped to HTTP VERB and to the server routine.

Components Schema Types. Each schema type can be mapped to Field, Integer, String, Array, Object, Boolean, or Number.

Security Schemes

What is the anatomy of a URL?

The RESTful endpoint of a URL consists of the application context, version, resource, and parameter.

How do I use the Code Generator to Create APIs?

Being part of the growing API economy is more important than ever. APIs are a vital aspect of the app development process as they serve as the key to access data from various platforms. With Visual LANSA 15, publishing APIs is as easy as drag and drop. Decrease app development times and increase your applicationโ€™s web availability by publishing your first API today.

Watch the Video Below:

How do I use the Visual LANSA Routing framework?

The latest release of Visual LANSA 15+ includes the new Visual LANSA Routing framework. It enables application developers to start with a blank page or template and gain full control over how the routing works. This allows for parent-child routes and supports nested routing resulting in the capability of nesting and navigating views within views within views.

Watch the Video Below:

Google Cloud Natural Language API: How can I analyze sentiment?

According to Google, “Sentiment Analysis inspects the given text and identifies the prevailing emotional opinion within the text, especially to determine a writer’s attitude as positive, negative, or neutral. Sentiment analysis is performed through the analyzeSentiment method.”

Check out the full ‘Analyzing Sentiment in a String’ example one Google.

Here is an example of performing sentiment analysis on a text stringย  with curl via the Natural Language API:

Protocol

curl -X POST \
ย  ย  ย -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
ย  ย  ย -H "Content-Type: application/json; charset=utf-8" \
ย  ย  ย --data "{
ย  'encodingType': 'UTF8',
ย  'document': {
ย  ย  'type': 'PLAIN_TEXT',
ย  ย  'content': 'Enjoy your vacation!'
ย  }
}" "https://language.googleapis.com/v1/documents:analyzeSentiment"

The response is in JSON format:

Protocol

{
ย  "documentSentiment": {
ย  ย  "magnitude": 0.8,
ย  ย  "score": 0.8
ย  },
ย  "language": "en",
ย  "sentences": [
ย  ย  {
ย  ย  ย  "text": {
ย  ย  ย  ย  "content": "Enjoy your vacation!",
ย  ย  ย  ย  "beginOffset": 0
ย  ย  ย  },
ย  ย  ย  "sentiment": {
ย  ย  ย  ย  "magnitude": 0.8,
ย  ย  ย  ย  "score": 0.8
ย  ย  ย  }
ย  ย  }
ย  ]
}

If the score is greater than zero then it is a positive sentiment and if it is less than zero then it is a negative sentiment.

Learn more about accessing REST APIs like this on Learn LANSA.

Google Cloud Vision API: How to detect Labels in a local image?

According to Google, “The Vision API can detect and extract information about entities in an image, across a broad group of categories. Labels can identify general objects, locations, activities, animal species, products, and more. If you need targeted custom labels,ย Cloud AutoML Vision allows you to train a custom machine learning model to classify images. This API is useful when creating Artificial Intelligence systems.”

Check out the full ‘Detect Labels in a local image’ article over on Google.

With this API you can send a base64 encoded mage to be used as image to detect the labels in. What this API you send a POST request toย  https://vision.googleapis.com/v1/images:annotate with the following body:

{
  "requests": [
    {
      "image": {
        "content": "base64-encoded-image"
      },
      "features": [
        {
          "maxResults": 5,
          "type": "LABEL_DETECTION"
        }
      ]
    }
  ]
}

The response to such a request might look like this:

{
  "responses": [
    {
      "labelAnnotations": [
        {
          "mid": "/m/01c8br",
          "description": "Street",
          "score": 0.87294734,
          "topicality": 0.87294734
        },
        {
          "mid": "/m/06pg22",
          "description": "Snapshot",
          "score": 0.8523099,
          "topicality": 0.8523099
        },
        {
          "mid": "/m/0dx1j",
          "description": "Town",
          "score": 0.8481104,
          "topicality": 0.8481104
        },
        {
          "mid": "/m/01d74z",
          "description": "Night",
          "score": 0.80408716,
          "topicality": 0.80408716
        },
        {
          "mid": "/m/01lwf0",
          "description": "Alley",
          "score": 0.7133322,
          "topicality": 0.7133322
        }
      ]
    }
  ]
}

Learn more about accessing REST APIs like this on Learn LANSA.

How can LANSA help you build powerful business solutions?

Whether you need to enhance/extend existing systems or you need full project life-cycle design, development, and implementation services โ€“ LANSA can help. Our rapid and repeatable solutions minimize costs and maximize results in these fields:

  • Mobile, Web, Dashboards, Business Intelligence
  • Event Notifications to Email, Text, and related systems
  • Workflow, CRM, WMS, Metadata Management
  • New business applications
  • RFID, Scanning, Barcoding, PLC Integration, GDSN
  • Integration of disparate systems

Deploy it all as a progressive web app!

Put your Enterprise on a better track, ย contact us today.

A smarter, faster way to deliver business software

ABOUT THE AUTHOR

LANSA Editors

LANSA is a professional low-code development platform that helps businesses efficiently build and modernize software. In this blog, the team draws on decades of experience empowering enterprises to innovate on the IBM i and future-proof their mission-critical systems.

More Articles

Are you ready for better conversations?

Integrated solutions that deliver powerful results.

Keep the light on.

Join our mailing list for development guides and solutions for constant IT innovation.