Overview
Installation
The TypeScript runtime environment is Node.js 20+, and only ESM is published. The Python runtime environment is 3.10+.
npm install @edgeone/makers-sdk
pip install makers-sdk
Obtaining an API Token
1. Create an API Token in the console. For steps, see API Token.
2. Write the
MAKERS_API_TOKEN environment variable.Initialization
import { Makers } from "@edgeone/makers-sdk";const makers = new Makers({token: process.env.MAKERS_API_TOKEN,region: "china",});
import osfrom makers_sdk import Makersmakers = Makers(token=os.environ["MAKERS_API_TOKEN"],region="china",)
region must match the site that issued the API Token: use "china" for the China site and "global" for the international site.If
region is not specified, the SDK automatically detects the China site (china) and the international site (global) in sequence, and caches the result in the current Makers instance.Constructor Parameters
Parameter names and types are given in the format of
TypeScript / Python.Parameter | Type | Required | Default Value | Description |
token | string / str | Yes | - | EdgeOne Makers API Token |
source | string / str | No | "sdk" | Source of the request. |
timeout | number / float | No | 30 | Timeout of a single request, in seconds. |
retries | number / int | No | 3 | Maximum number of retries for query operations; write operations are not retried. |
logger | Logger | No | - | Used to output SDK logs. Pass in an object with the debug, info, warn, and error methods. If it is not passed in, no logs are output. |
Public Members
Member | Type | Description |
makers.projects | Projects | Project and Environment Variable Operations |
makers.deployments | Deployments | Deployment Operations |
makers.tokens | Tokens | Issue tenant tokens ( tokens.create) |
makers.region | "china" | "global" | Read-only. The value passed during construction is China site ( china) or global site (global). If not specified, the value is the auto-detected result. |
Type names are the types exported by TypeScript, while the corresponding Python namespaces are not exported as public types.
Error Handling
All errors inherit from
MakersError, with public fields code, cause, requestId / request_id, and httpStatus / http_status. Error messages are obtained through error.message in TypeScript and through str(error) in Python.Exception Type | Description |
AuthError | Invalid Token or unauthorized access |
ValidationError | Invalid input parameters or validation errors returned by the server. Local validation is thrown before the request is sent. |
NotFoundError | Project or deployment does not exist |
ConflictError | Resource conflict, for example, the project name already exists. |
RateLimitError | Rate limit triggered |
UploadError | Failed to upload artifact |
TimeoutError | Timeout of a single request |
DeploymentTimeoutError | Timeout while waiting for the deployment to reach a final state (inherits from TimeoutError) |
import { Makers, MakersError, NotFoundError } from "@edgeone/makers-sdk";const makers = new Makers({token: process.env.MAKERS_API_TOKEN,region: "china",});try {await makers.projects.get({ projectId: "missing" });} catch (error) {if (error instanceof NotFoundError) {console.error(error.code, error.requestId, error.httpStatus);} else if (error instanceof MakersError) {console.error(error.code, error.message, error.requestId);}}
import osfrom makers_sdk import Makers, MakersError, NotFoundErrormakers = Makers(token=os.environ["MAKERS_API_TOKEN"],region="china",)try:makers.projects.get(project_id="missing")except NotFoundError as error:print(error.code, error.request_id, error.http_status)except MakersError as error:print(error.code, str(error), error.request_id)
Advanced: Issuing Tenant Tokens
tokens.create issues a tenant token. When initializing the current Makers, pass the primary API Token (account-level credential) created in the console to token. The SDK does not check whether the passed token is the primary API Token. Issued tenant tokens cannot be queried or deleted.
Upon successful invocation, the API returns
token, tokenId / token_id, and expired. expired is the expiration time in Unix timestamp format (seconds). When re-issuing for the same tenantId / tenant_id, token and tokenId / token_id remain unchanged, while expired may be updated. If the parameters do not meet the requirements, a ValidationError is thrown before the request is initiated.import { Makers } from "@edgeone/makers-sdk";const platform = new Makers({token: process.env.MAKERS_API_TOKEN,region: "china",});const { token, tokenId, expired } = await platform.tokens.create({tenantId: "user-open-id",name: "user-open-id",expiresIn: 86400,});const user = new Makers({token,region: "china",});const { projectId } = await user.projects.create({ name: "my-site" });await user.deployments.deploy({projectId,artifact: { files: { "index.html": "<h1>Hello</h1>" } },});
import osfrom makers_sdk import Makersplatform = Makers(token=os.environ["MAKERS_API_TOKEN"],region="china",)created = platform.tokens.create(tenant_id="user-open-id",name="user-open-id",expires_in=86400,)user = Makers(token=created["token"],region="china",)project = user.projects.create(name="my-site")user.deployments.deploy(project_id=project["project_id"],artifact={"files": {"index.html": "<h1>Hello</h1>"}},)
Parameter | Type | Required | Description |
tenantId / tenant_id | string / str | Yes | Tenant ID, up to 64 characters |
name | string / str | Yes | Token name, 1 to 128 characters in length |
expiresIn / expires_in | number / int | Yes | Validity period, in seconds, ranging from 10 to 315360000 |
