Integrate PWAs With Powerful Business Process And Artificial Intelligence REST APIs

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.

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.

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.


LANSA Hybrid Low-Code solutions are fast to deploy and easy to maintain delivering outstanding value for any application development project. Ready to get started?




Recommended Posts