Managing APIs‎ > ‎

Import and Export API Definitions

APIs are the definitions you create for your data sources. You can import/export API definitions. In the most basic case, you can export an API definition from API Server-1 into a file, save it in a source control system, and import it on API Server-2. This is effectively a copy of your API. A typical use is the life cycle operation to move a system from dev to production.

You can import API definitions in the following ways:

  • Interactively, using Live API Creator.
  • Using scripts or API calls, to make such operations repeatable.

Scripting requires more background. The following examples illustrate scripting the import process using cURL and NodeJS.

Import and Export Using Live API Creator

You can interactively export an API definition, import the API definition, and define the export file format.

Export an API Project as a JSON File

You can export your API as a .JSON file download. The export contains all the meta data for the current API including database schema, business rules, resource endpoints, security definitions for users, and roles. You can save the exported .JSON file into a source control system or import it into another account.

With your API open, on the Create, API Properties, Details tab, click Export.

The following image shows the organization of the.JSON export file. This file is an ordinary text file and can be large. You can view it in a text editor and check it into a source control system.

Important! Do not make changes to the contents of the file.

Import a Previously Exported JSON API Project File

You can import a previously exported JSON API file from within your open API or from the Home page. The following procedure explains how to import the file from within your open API.
  1. With your API open, on the Create, API Properties, Details tab, click Import.
    The Import window opens.
  2. Select the exported JSON file you want to import and click OK.
    The file is imported into the API Server.
If a project with the same name/URL already exists, the imported project is renamed to avoid collisions.

Fix the Imported Project

The .JSON export file does not include passwords and other security information. The authentication provider is preserved if possible or defaulted if not. You must re-supply this information.

For an example of importing an API, see the Logic Sample Project.

  1. With your API open, select Your Account from the gear icon menu at the top right of API Creator, respecify you database password, and then save your changes.
  2. On the Create, API Properties, Details tab, verify the authentication provider in the Authentication provider field.
  3. (If you are using the built-in authentication provider) Specify the admin passwordsFor the sample databases, we recommend that you use Password1.
    For more information about managing users using the built-in authentication provider, including how to change a user's password, see Authentication.
  4. (Optional) Respecify the URL name for your API, which includes the timestamp of the import.

Resource Import/Export

For more granular operations, you can import and export individual Custom Resource definitions.

Import API Definitions using Scripts or API Calls

You can script the export/import procedures. For example, you might want to automate the life cycle operation of moving an API from development to production. Scripting is based on the underlying concepts of programmatic API Creation.

For more information about the concepts of creating, developing, and testing APIs by way of programs, see Programmatic API Creation.

Live API Creator APIs consist of settings in the admin data and not in the code. You can access these settings (API definitions) by way of the Admin API, which is a RESTful API that accesses the admin data stored in the Admin database. These settings are the contents of the .JSON file export.

For more information about admin data, see Architecture.

Access Admin Data using the ProjectExport Resource

You can access admin data using the ProjectExport resource within the Admin API. Its response data is shown in the "Sample JSON Layout". Export is a GET and import is a POST on ProjectExport using this API.

Access Admin Data using the Admin API

You can access admin data using the Admin API. For example, you can use the API to create an API. You can do this using cURL commands, the Admin CLI, or the Node SDK.

For more information:

Manage your API Definitions using the Admin CLI

You can manage your API definitions using the Admin CLI, liveapicreator-admin-cli, which accesses the Admin API. The Admin CLI is a NodeJS application packaged so it operates from the command line.

For more information about the Admin CLI, see Admin CLI.

Access the Admin API using Node SDK

The Node SDK simplifies API access for NodeJS applications, with services to make auth IDs transparent, etc. You can manage your API definitions using the Node SDK by writing Node applications that you can employ in DevOp scripts.

For more information:

Import/Export Best Practices

Before you export a project to create a production server, we recommend that you complete the following:
  • Remove unused data sources.
Note: You might have test/dev data sources. Remove what is not required.
  • Clear unused libraries.
Logic libraries are not exported with the API definition. Development teams should maintain these libraries so that they can be reloaded onto the production target. Your import scripts can reload these libraries by way of the Admin API.

Live API Creator is accessed by way of normal HTTP(s). If you are deploying to a cluster, use your normal load balancing approach. Each of the nodes in the cluster should use the same Admin database.

For more information: