Skip to main content

API Route

To create and manage an API route trigger.

An API Route can be invoked by HTTP requests. A data process linked to an API route is essentially a web service or a HTTP endpoint.

Create an API Route

  1. In LOC Studio, go to TriggerAPI Route.
Nav-api-route
  1. An API route belongs to a project, which can be created in the data process explorer. Create one if needed.
API-route-explorer
  1. Click Create API Route on the top right, or right-click a project and select the same option.
Create-api-route
or
Menu-create-api-route
API Route Usage Limit

You won't be able to create new API routes if existing ones have reached the maximum limit specified in your license. (See: Inspect License.)

An ad hoc version of Studio 2.0.0 also shows the API usage (for example, Api-route-limit) on the upper right corner of the API route screen.

  1. Fill in the fields in the API route creation window.
API-route-creation
API Route Fields Description
FieldRequired?Description
API Route NameYesAPI route name (up to 128 characters)
DescriptionNoAPI route description
HTTP MethodYesAllowed HTTP method in HTTP requests
URLYesAPI route path (for example, /path or /api/path)
Request ModeYesSynchronous (wait for task results) or asynchronous (do not wait for task results)
Response Content TypeYesContent type of the HTTP response
EncapsulationYesEncapsulate execution metadata (default true)
API TasksYesData processes to be linked
tip

You can create multiple API routes with the same path that accept different HTTP methods.

  1. Search data processes and click + API Task to link them.
API-route-add-task
  1. Fof the linked data processes, you can also quickly select the latest revision Setting or delete Trash them.
API-route-task
  1. Click Create to create the API route.
API Route Encapsulation

Normally, the body of a HTTP response returned from an API route will contain

  • Metadata of the execution
  • Metadata and task results combined from all tasks in the execution

If Encapsulation is set to false, the response will only contain task results. Since the task results are entirely defined by users, this is a way to create RESTful APIs in LOC.

Edit or Delete an API Route

Select an API route and click Edit API Route Save or Delete API Route Delete on the top right, or right-click and select the same options.

Menu-api-route-edit

Invoke an API Route

To execute a data process without an actual API route, see Manual Execution.

The URL of a created API route, for example, https://api.xxxxxx.fst.network/api/path is the HTTP endpoint that can accept specific methods from any HTTP clients:

curl -X GET 'https://api.xxxxxx.fst.network/api/path'

curl -X POST -d '{
"key": "value"
}' 'https://api.xxxxxx.fst.network/api/path'

API Route HTTP Status Code

An API route may return one of the following HTTP status code:

HTTP Status CodeDescription
200The execution has completed with or without errors.
202The execution time has exceeds 15 seconds in synchronous mode (timed out). The execution may still complete later.
404The API route is not found. If you have just created the API route, wait a moment then try again
405The API route exists but you are using incorrect HTTP request methods.
info

User can also use result agent to set a different HTTP status code when the execution completes.