Customize your API

You can customize and shape your API by explicitly defining RESTful endpoints, or resources, using API Creator, by adding custom endpoints, or by creating functions. This article focuses on the resources that you can explicitly define.
calac41
You can customize and shape your API by explicitly defining RESTful endpoints, or resources, using API Creator, by adding custom endpoints, or by creating functions. This article focuses on the resources that you can explicitly define.
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
Functions
Custom Endpoints
Can include JavaScript code
 
Yes
 
 
Yes
 
 
Yes
 
 
Yes
 
Are data-oriented
 
Yes
 
 
Yes
, as defined in the code
 
Yes
 
No
Provide a data abstraction layer for database access
 
Yes
 
 
Yes
, as defined in the code
No
No
Can return JSON responses
 
Yes
 
 
Yes
 
 
Yes
 
 
Yes
 
Can return HTML responses
No
No
No
 
Yes
 
Can return XML responses
 
Yes
 
 
Yes
 
 
Yes
 
 
Yes
 
Are associated to entities (tables or views)
 
Yes
 
No
Optionally
No
 You can invoke tables, views, and resources using the 
SysUtility
 object in your custom endpoint's JavaScript code.
For more information about how to use this object, see The SysUtility Object.
Have input parameters
No
No
 
Yes
 
No
Can be called using HTTP methods
GET, POST, PUT, and DELETE
GET and POST
GET
GET, POST, PUT, and DELETE
Are included in Swagger documentation
 
Yes
 
 
Yes
 
 
Yes
 
No
Are authenticated
 
Yes
 
 
Yes
 
 
Yes
 
Optionally
In this article:
 
 
2
 
 
Sources for Resources
Your API can consist of the resources that you explicitly define using API Creator and schema resources. Schema resources are the tables, views, and stored procedures 
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.
You can insulate your database and can reduce latency by migrating the schema resources to explicitly defined resources, and then define logic and security. You do not have to expose your entire database or rewrite existing logic.
The resources that you can explicitly define in your API 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. The resources that you explicitly define 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 is passed 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.
Resource Types
You can explicitly define the following type of resources:
View your List of Resources
The resources that you can explicitly define are displayed in the list of resources, on the Resources page. You can identify the resource type for the resources that you have explicitly defined in your API 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.
Apply Filters and Sorts to Each Level of the Endpoint
For more information:
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.
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.