Use SE2's APIs from JS/TS
You can find a detailed specification of SE2’s APIs here.
Use our JavaScript SDK to easily interact with SE2’s APIs using JavaScript or TypeScript.
Install SE2 for JS/TS
Setup
Import the library and configure the client. The default configuration will point the client at SE2’s default production URLs in your cluster.
A configuration for local development is also provided.
Default Config
By default, the client will point to the control plane and data plane within your Kubernetes cluster.
Local config
For local development with SE2 running in docker-compose, the local configuration will point to the services running on your local machine.
Custom API URLs or ports
Getting started
Using the SE2 APIs, this guide will use the Administrative and Execution APIs to get a list of available plugins and execute one.
The Administrative APIs getPlugins
method takes an object with a userId
and a namespace
and returns a list of available plugins for that user in the provided namespace.
Example output
The result includes a plugin named foo
(which for this tutorial already exists) and which we will execute using the Execution APIs run
method.
The run
method takes an object with the environment
, userId
, namespace
, extName
, and version
, and returns the result of the executed plugin.
Full API
These are all of the available methods.
Admin
suborbital.admin.getToken
Description: Retrieves an authentication token for the given plugin, typically used to authenticate calls to the Builder API. Args: An object containing environment
, userId
, namespace
, pluginName
. Result: A string containing the token used for authorization.
suborbital.admin.getPlugins
Description: Returns a list of available plugins for the given user in the given namespace. Args: An object containing userId
, namespace
. Result:
suborbital.admin.getExecutionResult
Description: Returns the most recent results (up to 5) produced by the execution of the given plugin. Args: An object containing environment
, userId
, namespace
, pluginName
, version
. Result:
Exec
suborbital.exec.run
Description: Executes the given plugin, with the provided body, params and state loaded into the extension at runtime. Args: An object containing environment
,userId
,namespace
, pluginName
,version
. Result: The result of the executed plugin.
Builder
suborbital.builder.build
Description: Builds the provided code using the specified language toolchain. Args: An object containing language
, environment
, userId
, namespace
, pluginName
, token
. Result: A string containing the logs for the build.
suborbital.builder.getDraft
Description: Gets the draft for the specified runnable. Args: An object containing environment
, userId
, namespace
, pluginName
, token
. Result: A specified runnable.
suborbital.builder.deployDraft
Description: Deploys the specified runnable. Args: An object containing environment
, userId
, namespace
, pluginName
, token
. Result: A string containing the version.
suborbital.builder.testDraft
Description: Tests the draft for the specified runnable. Args: An object containing environment
, userId
, namespace
, pluginName
. Result: A string containing the result.
suborbital.builder.getTemplate
Description: Gets the template (which controls what your users see when they create a new plugin) for a new extension of the given language. Args: An object containing pluginName
, language
. Result: