Requirements    
Prerequisite knowledge
Required products
User level
No Prerequisite knowledge required
Adobe ColdFusion Enterprise Edition (2016 release) (Download trial)
All

 
Introduction

This article describes three different ways of creating an API using the API Manager platform. They are:
  1. Creating an API manually
  2. Importing an API from swagger
  3. Importing an API from ColdFusion
This article also describes how to consume an API.

 
Create REST API manually

As an example of creating an API manually from scratch, you can build an API, GenderChecker. The API takes a name as input and returns if the name belongs to a male or a female.
The server side of this API already exists, as shown below:
http://truefbfriends.com/analysis?firstname=john
In the example, 'http://truefbfriends.com' is the endpoint, 'analysis' is a resource, and 'firstname’ is the parameter.
To create the API using API Manager:
 
Step 1
Log in to the API Manager portal as publisher.
 
Fig1
 
Step 2
After you log in, click Create API on the left navigation panel. Click Create REST API.
 
Fig2
 
Step 3
Enter the details of the API. You can assign any meaningful name to the API. Specify the endpoint as 'http://truefbfriends.com'
 
Fig3
 
Step 4
Now move to the Resources section. The example API has only one resource, which you can add. Enter /analysis and choose GET method. To add the resource, click Add Resource. You can expand the resource by clicking on the green arrow.
 
Fig4
 
Step 5
Add the parameter firstname. The parameter is of type query.
 
Fig5
 
Step 6
To publish the API, click Publish.
 
Fig6
 
Step 7
Once the API is published, you can preview of the API. You can verify the details and if required, edit and re-publish the API.
 
Fig7
 
Step 8
To test this API, click Test this API on the left navigation panel. Expand the resource.
 
Fig8
 
Step 9
Enter the value of parameter firstname. Choose Produces. Here, there is a single option. And finally, click Run API Call. Once the API call is complete, you can see the result along with the response and request details.
 
Fig9
The REST API is complete and is ready for use.
 

 
Create API from swagger

Swagger is a formal specification surrounded by a large ecosystem of tools, which includes everything from front-end user interfaces, low-level code libraries, and commercial API management solutions. The API Manager supports importing an API from Swagger 1.2 and Swagger 2.0..
To import a Swagger doc:
 
 
Step 1
In the Create API page, click  Import REST API from Swagger.
 
Fig10
 
Step 2
Enter the URL of the Swagger doc. In this example, use petstore’s swagger doc.
 
Fig11
 
Step 3
After clicking Import , the REST API is generated using this Swagger doc. Details like version, description, and so on are fetched from the Swagger doc.
 
Fig12
 
Step 4
In the Resources section, you can view all the resources of the Petstore Swagger doc.
 
Fig13
 
Step 5
To publish the API, click Publish.
 
Step 6
Test the API.
 
Fig14
The API imported from a Swagger doc is now ready for use.

 
Create API from ColdFusion

In the API manager, you can also import REST services registered in any ColdFusion server. To register a ColdFusion server with the API Manager:
 
Step 1
In ColdFusion administrator, you can enable discovery of rest services. In the settings page, enable the option.
 
Fig15
 
Step 2
Register a REST service. The service is a basic CFC that returns the current date.
 
Fig16
 
Step 3
Register the REST service in ColdFusion admin.
 
Fig17
 
Step 4
In the API Manager administrator, register the ColdFusion server.
 
Fig18
 
Step 5
In the API Manager portal’s Create API page, click Import REST API from ColdFusion. You can see a pop-up containing all registered ColdFusion servers and all registered REST services.
 
Fig19
 
Step 6
Import any REST service. You can see the resources.
 
Fig20
 
Step 7
Publish and test your API.
 
Fig21
The ColdFusion REST service is ready for use via the API Manager.

 
Subscribing to an API

Once you publish an API, consumers can consume it.
 
Step 1
As a publisher, you can create an API. To subscribe to an API, switch to subscriber view.
 
Fig22
 
Step 2
Navigate to the API catalog to browse all publicly available APIs. Click on any API you want to subscribe.
 
Fig23
 
Step 3
Once you click an API, you can see all the details of the API. You can even try out the API before subscribing to it.
 
Fig24
 
Step 4
Go to the Subscribe section. Choose the application you want to subscribe Choose the SLA plan you want to subscribe to and finally click Subscribe. You can now use the application key to invoke the API.
 
Fig25

 
Where to go from here

In the next few articles, we will describe how to create REST API from SOAP, importing SOAP API, and other advanced features of API Manager.