Import and Export APIs

Import and Export APIs
You can create a backup of your API by exporting it. In the most basic case, you can export an API 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 development to production.
In this article:
Import/Export Best Practices
Before you export an API to create a production server, we recommend that you complete the following:
  • Remove unused data sources.
    You might have test/dev data sources. Remove what is not required.
  • Clear unused libraries.
Logic libraries are not exported with the API. Development teams should maintain these libraries so that they can reload them onto the production target. Your import scripts can reload these libraries by way of the CA Live API Creator Admin project API (Admin API).
CA Live API Creator
 is accessed by way of normal HTTP(s).
You can import APIs in the following ways:
Import and Export Using API Creator
You can interactively export an API, import the API, and define the export file format.
Export an API as a JSON File
You can export your API as a 
 file download. The export contains all the metadata for the current API including database schema, business rules, resource endpoints, security definitions for users, and roles.
The following image shows the organization of the
 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.
Do not make changes to the contents of the file.
  1. With your API open, under the Create menu, click 
    API Properties
    The Details appears.
  2. Click 
     file is dowloaded.
  3. Do one of the following:
    • Save the exported 
       file into a source control system.
    • Import the exported 
       file into another API.
Import a Previously Exported API
  1. From the Home page, click 
    The Import window opens.
  2. Select the exported
    file you want to import and click 
    . The
    file is imported into the API Server.
    If an API with the same name/URL already exists, the imported API is renamed to avoid collisions.
The exported API (
 file) is imported into a new API.
Fix the Imported API
The exported 
 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 how to import an API, see the Business Logic API Project Sample.
  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. under the Create menu, click 
    API Properties
    The Details page appears.
  3. Verify the authentication provider in the 
    Authentication provider
  4. (If you are using the built-in authentication provider) Specify the admin passwords
    For more information about managing users using the built-in authentication provider, including how to change a user's password, see Authentication.
  5. (Optional) Respecify the URL name for your API, which includes the timestamp of the import.
The API is fixed.
Import APIs 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. Scripting requires more background. The following examples illustrate scripting the import process using cURL and NodeJS.
CA Live API Creator
 APIs consist of settings in the admin data and not in the code. These settings are the contents of the 
 file export. You can access these settings (APIs) by way of the Admin API. This API is a RESTful API that accesses the admin data stored in the Admin database.
Access Admin Data using the ProjectExport Resource
You can access admin data using the 
 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
using this API.
Access Admin Data using the Admin API
You can access admin data using the Admin API. For example, you can use this API to create an API. You can do this using cURL commands, the Admin command-line interface (Admin CLI), or the Node SDK.
For more information:
Manage your APIs using the Admin CLI
You can manage your APIs using the 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:
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 APIs using the Node SDK by writing Node applications that you can employ in DevOp scripts.
For more information:
Update APIs While Running in a Cluster
If you need to update an API while running in cluster, complete the following process:
  1. Stop all nodes in the cluster.
  2. Import the API.
  3. Restart the nodes.