Import a database as an API

Axway AMPLIFY API Management provides a standard, vendor-agnostic abstraction layer for making databases accessible in the Cloud. This is an important step to ensure you keep control over your data, guaranteeing security, monitoring, and management. If your job involves making database requests, you should almost never be sending queries directly to that database, unless you are involved in developing core APIs.

The tool that transforms databases into APIs is API Builder.

In the following procedure, we will import build an API using API Builder, then publish it in the cloud, then register it using API Manager.

Time to complete: 45 min approx. User role: data integrator. Difficulty: this involves downloading and installing software on your computer; the result may depend on your configuration and other factors. 

Build an API using API Builder

Install API Builder

The following steps will install API Builder locally on your workstation. To do this, we will log in to a different environment, the Axway platform. 

Note   The Platform and the Trial environment (that we have been working with up to now) are due to be merged soon into a single entity.
  1. You can if you wish close any of the tabs still open from the previous steps.
  2. Open the Axway platform at
  3. Unless you already have an account on this platform, then click Don't have an account? Get started for free.
  4. Follow the steps indicated in the Create your Account pages. You will receive credentials via email: note them down.
  5. Once you are registered and logged in, click on the griffin logo, then select API Builder
  6. This opens a page explaining how to setup API Builder. Follow the instructions in the Setup section.
    Note: don't start the Create a project section quite yet, as it is the subject of the next step.
    Once you have finished the Setup section, added to API Builder, you have installed on your system node.js and the npm command, a tool used by JavaScript developers to download or upload applications.

Create an API Builder project

In this example, we are creating a project to contain data about aircraft. We'll call it planeDB.

  1. In the command line window, enter the command indicated in the Create a project section: appc new -t arrow
  2. When the dialog requests What's the project name? , type in planeDB
  3. You may be asked to re-enter your Appcelerator credentials
  4. Type in the command cd planeDB to reach the newly created folder for the project
  5. Type in appc run to start the project
    It may take a minute for API Builder to start up.
    Once you see the line server started on port 8080, the API builder project is ready

Create the database with API Builder

  1. In a new browser tab, open the API builder in a browser, at the following address:
    It looks like this:

  2. Expand the menu using the button (bottom left), then select
  3. Click to create the new model
  4. Fill in the form
    Model name: plane
    Description: Plane Database
  5. Click Next
  6. Click the +Field button to create a new field
  7. Create 3 new fields:
    • model (string)
    • manufacturer (string)
    • wingspan (number)
  8. Click Next >
  9. We are now requested to select which CRUD commands (Create-Retrieve-Update-Delete) we want to make available as API methods to manipulate our database. Leave all of these checked and click Save.
  10. Once the model is loaded, the list of models appears again, this time including the plane model.
  11. In the right-hand menu, click API Docs & Test, then select the plane API in the list
  12. To check how may planes we have, click GET /api/plane/count
  13. The Test API page opens. Click the Execute button
  14. The result page appears, it looks like this. For the moment, there is no entry in the database:
  15. Go back to the Test API page and edit the body to include values for the model, manufacturer and wingspan, as follows:
  16. Click Update
  17. Return the /plane page, select > POST, then Create a plane. Enter the following plane descriptions, one after the other (click Create button each time):
    • "model": "172"
      "manufacturer": "cesna"
      "wingspan": "11"

    • "model": "A380"
      "manufacturer": "airbus"
      "wingspan": "80"

    • "model": "G650"
      "manufacturer": "gulfstream"
      "wingspan": "30"
  18. Click GET /api/plane/ then Execute button. The Result field should show all the planes. 

Publish the API in the cloud

We have now successfully created an API, and filled it with data. The next step is to publish it in the Axway API platform, so that we can run in the cloud.

  1. Open a command line window, navigate to the apibuilder/planedb/ directory that was created by the process above.
  2. Enter the command appc publish
  3. Wait a few seconds while Appcelerator packages all the entries. The message appears:
    Published api/planedb@1.0.0
  4. Return to the API Builder Arrow Quick start page
  5. Click Apps > planedb
    The planedb page appears:

Proxy the API using API Manager

Now we are going to proxy the API and secure it with API Manager.

  1. Open the API builder console and click on the Configuration entry to the left:
  2. Click on default.js in the list
  3. Copy the API key
  4. Keeping this second tab open (so we can return to it later), open API Manager and sign in with your API Manager ID
  5. Click on API > Backend API > New API > Import from API Builder
  6. Enter your Appcelerator ID, then select the API you just built, and click on Import.
  7. The planedb API appears in the list. Click on it. A list of methods is available
  8. Click Frontend API > New api > New API from Backend API
  9. Select the existing backend API: planedb 1.0.0
  10. In the Inbound tab, select the Inbound security: Pass Through and the Resource path /planedb
  11. Click the Outbound tab to configure the Outbound authentication profile, so that you can call the API running in the cloud.
  12. In Outbound authentication profile, select HTTP Basic
  13. Collect the API key in the second tab and copy-paste it into the User name . Leave the password empty.
  14. Click the Apply button above
  15. Click on API Methods tab, then select the findPlaneCount method
  16. Click Try method
  17. Go to API > Frontend APIcreatePlane method
  18. Enter the following in the body:
    "model": "172",
    "manufacturer": "cesna",
    "wingspan": "11"
    "model": "A380",
    "manufacturer": "airbus",
    "wingspan": "80"
    "model": "G650",
    "manufacturer": "gulfstream",
    "wingspan": "30"
  19. Click Try method button. The planes appear!


Related Links