Skip to main content

APIs

APIs provide a flexible way to invoke the V2 version APIs Connector. For creating V2 version APIs, see the documentation.

Note

The v3 version uses the open capabilities of the HTTP API when calling general APIs.


APIs Usage Reference

interface apis {
[apisLabel: string]: {
[
method: "request" | "post" | "get" | "head" | "patch" | "delete" | "put"
]: (
callApiOptions: ICallApiOptions,
opts?: IRequestOptions
) => Promise<ResponseObject["data"]>;
};
}

APIs module supports the following HTTP methods:

MethodDescriptionExample
getGET requestapis["apisLabel"].get(callApiOptions)
postPOST requestapis["apisLabel"].post(callApiOptions)
putPUT requestapis["apisLabel"].put(callApiOptions)
deleteDELETE requestapis["apisLabel"].delete(callApiOptions)
headHEAD requestapis["apisLabel"].head(callApiOptions)
patchPATCH requestapis["apisLabel"].patch(callApiOptions)
requestCustom method requestapis["apisLabel"].request(callApiOptions)
Tip

apisLabel is the APIs identifier, generated when creating the V2 version APIs Connector, and can be found in the connector's basic information.

参数

callApiOptions
ICallApiOptions
opts
IRequestOptions

Request object parameters, generally not required to be passed, include url, method, headers, and body. They serve as supplementary options for customization needs and will override parameters of the same name in callApiOptions.

返回

res
ResponseObject['data']

data content returned by the HTTP interface

示例

import cloudbase from "@cloudbase/js-sdk";

// Initialize the CloudBase app
const app = cloudbase.init({
env: "your-env-id", // Replace with your Environment ID
region: "ap-shanghai", // region, defaults to Shanghai
accessKey: "", // fill in the generated Publishable Key
});

// obtain apis instance
const apis = app.apis;