Customize your API

You can customize and shape your API by defining RESTful endpoints, or resources, explicitly using API Creator, by creating functions, or by adding custom endpoints. This article focuses on the resources that you can define explicitly using API Creator.
lac42
You can customize and shape your API by defining RESTful endpoints, or resources, explicitly using API Creator, by creating functions, or by adding custom endpoints. This article focuses on the resources that you can define explicitly using API Creator.
For more information:
Use the following table to guide you on which endpoint type to define for your API:
Task
Table-based Resources
JavaScript Resources
Free SQL Resources
Functions
Custom Endpoints
Can include JavaScript code
 
Yes
 
 
Yes
 
No
 
Yes
 
 
Yes
 
Can include subresources
 
Yes
 
No
No
No
No
Can include row events
 
Yes
 
No
 
Yes
 
N/A
N/A
Are data-oriented
 
Yes
 
 
Yes
, as defined in the code
 
Yes
 
 
Yes
 
No
Provide a database abstraction layer
 
Yes
 
 
Yes
, as defined in the code
 
Yes
 
No
No
Can return JSON responses
 
Yes
 
 
Yes
 
 
Yes
 
 
Yes
 
 
Yes
 
Can return HTML responses
No
No
 
Yes
 
No
 
Yes
 
Can return XML responses
 
Yes
 
 
Yes
 
 
Yes
 
 
Yes
 
 
Yes
 
Are associated to entities (tables or views)
 
Yes
 
No
No
 
Optionally
 
No
 Custom endpoints can invoke entities and resources.
For more information, see Manage Custom Endpoints.
Have input parameters
No
No
 
Yes
 
 
Yes
 
No
Can be called using HTTP methods
GET, POST, PUT, and DELETE
GET and POST
GET
GET and POST
GET, POST, PUT, and DELETE
Are included in OpenAPI (Swagger) documentation
 
Yes
 
 
Yes
 
 
Yes
 
 
Yes
 
No
Are authenticated
 
Yes
 
 
Yes
 
 
Yes
 
 
Yes
 
Optionally
In this article:
 
 
2
 
 
Sources for Resources
Your API can consist of the resources that you define explicitly in your API using API Creator and schema resources. Schema resources are the tables, views, and stored procedures that 
CA Live API Creator
 exposes when you create your API and connect to a database. 
CA Live API Creator
 creates these schema resources by scanning the schema for the table-based resources, views, and stored procedures. You can begin client development in parallel with logic development using the schema resources.
Insulate your database and reduce latency instead of exposing your database or rewriting existing logic. Migrate your schema resources as resources that you define explicitly in API Creator, and then define your logic and security.
You can define explicitly the following types of resources in your API:
The resources that you can define explicitly provide a data abstraction layer, where you can choose and alias the data that you want to present. These resources are loosely akin to database views, where you can define named projections, filters, and alias names. They drive the mapping process. 
CA Live API Creator
 transforms resource rows to table rows for business-logic processing and persistence.
When you create an API and you connect to your database, 
CA Live API Creator
 also creates (not code generation) the JavaScript object model, made available through the 
row
 variable that it passes into your logic. This object model reads and writes data by addressing attribute/object accessors and persistence services.
For more information:
  • About the JavaScript object model and how 
    CA Live API Creator
     creates row objects for your base tables, see Row Objects.
  • About the 
    row
     variable, see Resource Row Events.
View your List of Resources
The resources that you can define explicitly in your API are displayed in the list of resources, on the Resources page. To view this page, with your API open, in the Create section, click 
Resources
.
You can identify the resource type for these resources using the icons that display to the left of the resource name in the list of resources:
Icon
Description
Identifies the resource as a table-based resource.
Identifies the resource as a Free SQL resource.
Identifies the resource as a JavaScript resource.
Identifies the resource as a MongoDB resource.
Identifies the resource as including row events.
Test Resources
You can test your resource in the REST Lab.
 
Follow these steps:
 
  1. Open the API containing the resource that you want to test.
  2. In the Create section, click 
    Resources
    .
    The Resource page appears.
  3. Select the resource that you want to test from the list of resources, and then click 
    Test
    .
The REST Lab opens.
 To return to the Resources page from the REST Lab, click 
Edit
.
Export Resources
For more granular operations, you can move individual resources from one API to another by importing and exporting them.
 
Follow these steps:
 
  1. Open the API containing the resource that you want to export.
  2. In the Create section, click 
    Resources
    .
    The Resource page appears.
  3. Select the resource that you want to export from the list of resources, and then click 
    Export
    .
.JSON
 file containing the exported resource is downloaded.
Import Resources
You can import a previously exported resource.
 
Follow these steps:
 
  1. Open the API to which you want to import the exported resources.
  2. In the Create section, click 
    Resources
    .
    The Resource page appears.
  3. Click 
    Import
    .
    The Import JSON window opens.
  4. Select the exported 
    .JSON
     file that you want to import, and then click 
    OK
    .
    The 
    .JSON
     file containing the exported resource is imported into the API.
The newly imported resource is imported and displays in the list.