Skip to main content

General Cloud API Calls

v3.0.0+

The tcb api command has been available since v3.0.0.

The tcb api command provides a unified access point for Tencent Cloud API calls, allowing direct invocation of any Tencent Cloud API interface via the command line without manual authentication processing or request encapsulation.

Basic Usage​

tcb api <service> <action> [options]

Parameter Description:

ParameterDescriptionRequired
<service>Tencent Cloud service name, such as tcb, scf, clsYes
<action>API Action name, such as DescribeEnvsYes
--body <json>Request body, JSON stringNo
--api-version <version>API version number, such as 2019-09-24 (optional; if not specified, the service default version is used)No
-e, --env-id <envId>CloudBase environment IDNo
--jsonOutput the result in JSON formatNo

Usage Example​

# List All TCB Environments
tcb api tcb DescribeEnvs

# Query Specific Environment
tcb api tcb DescribeEnvs --body '{"EnvId":"my-env-id"}'

# List SCF Functions (Environment Must Be Specified)
tcb api scf ListFunctions -e my-env-id

# Specify API Version
tcb api tcb DescribeEnvs --api-version 2019-09-24

# Output in JSON Format (Suitable for Script Processing)
tcb api tcb DescribeEnvs --json

How to Find service and action?​

  • Tencent Cloud API Documentation: https://cloud.tencent.com/document/api
    • service corresponds to the API domain prefix for each product, such as tcb (CloudBase), scf (SCF), cls (Cloud Log Service)
    • action corresponds to the specific API name, such as DescribeEnvs, ListFunctions
tip

The tcb api command uses the credentials of the currently logged-in account for authentication, without requiring additional configuration of keys. Before making calls, ensure you have executed tcb login.

Command Quick Reference​

CommandDescription
tcb api <service> <action>Call Tencent Cloud API
tcb api <service> <action> --body <json>Call with a request body
tcb api <service> <action> --jsonOutputs in JSON format