REST Integration Examples

You can address the following integration subjects using Live API Creator:

  • Unified API. Application developers require APIs that hide the complexity of data in multiple locations without reducing performance from multiple calls.
  • Data synchronization. Enterprise databases need to share information, with synchronization between systems that store common data.
  • RESTful services. You can simplify business logic by leveraging existing software, for example, address validation.
  • Existing software. Business logic must leverage the investment in existing software libraries.

API Creator Background

Use the following elements as a background for exploring integration:

API Server as RESTful Server

API Server is built on REST. Your other servers can make RESTful calls to API Server to GET data, and PUT/POST/DELETE it, all subject to logic and security.

API Creator as RESTful Client: JavaScript Integration

You can invoke other RESTful services, whether for unified API or for update processing to address Data Synchronization and utilization RESTful services using API Server as a natural server. You can provide server-side JavaScript handlers using the JavaScript object model that Live API Creator builds. You can use these to invoke anything you need, including RESTful services.

For more information about the JavaScript object model, see Customize your API.

Rich Resource Model

You can define resource endpoints that provide document-oriented (tree) JSON responses.

Example: Pure SQL

With your database connected to API Creator, define the following resource by selecting tables. The following image shows the Create, Resource, Resource tab:

API Creator automates the joins from the foreign key, which you can override. Your resource is executable. The result is returned in the REST Lab, as shown in the following image of the Execute, REST Lab, Request tab: 
Observe the customer data (lines 7-8) includes Orders data (lines 9-18). The lists are paginated.

Unified API

API Creator resources, or endpoints, provide a document-model-based API that you can call, with functionality for joining multiple tables, projecting the desired rows and columns, and aliasing names for a clean API.

These services extend beyond relational data, so you can define resources that combine data from multiple sources. The following image shows an example on the Create, Resources, Details tab:



If you are starting without an existing API, connect API Creator and define the resource. The example illustrates how to invoke an existing API. If you do not have an API, you can:

  1. Stand up an API Creator REST server for the target database, which provides a RESTful API.
  2. Create a resource that returns the desired data, using the join, project, and alias functionality.
  3. Call it as shown in the example.

Data Synchronization

Experience has taught us that large, single corporate databases prove cumbersome to design and iterate. It is typically better to create databases that address a single function, and share data as required.

Such sharing might be performed without replicating data between databases, as shown in the previous example. On the other hand, if the shared data is required to complete transactions, it may be better to synchronize copies it between systems. There following are implications:

  • Business objects. Synchronization typically involves business objects comprised of multiple rows, such as a customer and their addresses.
  • Transformations. Table and column are typically not the same between systems, so a translation layer is required for name mapping.
  • Update logic. Updates must be trapped and analyzed to see if they require synchronization. The logic should be replicated in each client.
Live API Creator makes this really simple. Consider the following cases: client (where you send synchronization messages) and server (where such messages are sent).

Synchronization Clients

In this scenario, updates to API Creator data are to be transformed and sent to a remote system. Complete the following:
  1. Transformation. Create a resource that matches the remote system names for objects and attributes.
    Note: This can be a business object, a set of related rows. In the following image, the business object is called cust:
  2. Update Logic. Create an event handler (all API Creator updates publish events you can handle in server-side JavaScript), where you can:
    • Create a JSON string, per the format of the resource you created, using the SysUtility.getResource service.
    • Send it to the remote system by a direct POST, by placing it on an Enterprise Service Bus, or by using a guaranteed delivery service.

Synchronization Servers

Conversely, API Creator can also play the role of server, that is, receiving changes from a remote system. In the simplest case, you can:

  1. Define a resource matching the format of the incoming message (cust as shown in the previous example).
  2. When you POST that resource, API Creator performs the translation and inserts the data, including any associated business rules.

While simple, consider this subtlety. While you may want to POST the data the first time, what about subsequent changes from the remote system? You could ask the remote system to issue a PUT instead. While that works, it is not really reasonable for them to "remember" which related system has received what data. MergeInsert is a business object payload that inserts if it does exist, and updates if it does. You can define your match logic and API Creator runs the business logic associated with the updated data.

REST Service Integration

Data synchronization is useful, but the advent of RESTful Web services has ushered in a new era of services, such as addressing validation and credit checks, that are useful in business logic. API Creator provides server-side JavaScript, wherein you can invoke such services from events or validation rules. In either case, you can invoke such services under the proper conditions (for example, only when designated values change) using transaction context, such as row and oldRow.

Existing Software Integration

The final piece of the integration puzzle is the library of software assets your organization has been accruing for years. API Creator preserves this investment. You can upload existing JAR files or JavaScript libraries. From business logic events or rules, you can invoke these using server-side JavaScript.