Movatterモバイル変換


[0]ホーム

URL:


Skip to content
appwriteappwrite
Go to Console
appwriteappwrite

Functions

SERVER
Base URL
https://<REGION>.cloud.appwrite.io/v1

Create function

Create a new function. You can pass a list ofpermissions to allow different project users or team with access to execute the function using the client API.

Endpoint
POST /functions
Node.js
const sdk =require('node-appwrite');const client =new sdk.Client()    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')// Your API Endpoint    .setProject('<YOUR_PROJECT_ID>')// Your project ID    .setKey('<YOUR_API_KEY>');// Your secret API keyconst functions =new sdk.Functions(client);const result =await functions.create('<FUNCTION_ID>',// functionId'<NAME>',// name    sdk..Node145,// runtime    ["any"],// execute (optional)    [],// events (optional)'',// schedule (optional)1,// timeout (optional)false,// enabled (optional)false,// logging (optional)'<ENTRYPOINT>',// entrypoint (optional)'<COMMANDS>',// commands (optional)    [],// scopes (optional)'<INSTALLATION_ID>',// installationId (optional)'<PROVIDER_REPOSITORY_ID>',// providerRepositoryId (optional)'<PROVIDER_BRANCH>',// providerBranch (optional)false,// providerSilentMode (optional)'<PROVIDER_ROOT_DIRECTORY>',// providerRootDirectory (optional)''// specification (optional));
Endpoint
GET /functions/{functionId}
Node.js
const sdk =require('node-appwrite');const client =new sdk.Client()    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')// Your API Endpoint    .setProject('<YOUR_PROJECT_ID>')// Your project ID    .setKey('<YOUR_API_KEY>');// Your secret API keyconst functions =new sdk.Functions(client);const result =await functions.get('<FUNCTION_ID>'// functionId);

List functions

Get a list of all the project's functions. You can use the query params to filter your results.

Endpoint
GET /functions
Node.js
const sdk =require('node-appwrite');const client =new sdk.Client()    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')// Your API Endpoint    .setProject('<YOUR_PROJECT_ID>')// Your project ID    .setKey('<YOUR_API_KEY>');// Your secret API keyconst functions =new sdk.Functions(client);const result =await functions.list(    [],// queries (optional)'<SEARCH>'// search (optional));

Update function

Update function by its unique ID.

Endpoint
PUT /functions/{functionId}
Node.js
const sdk =require('node-appwrite');const client =new sdk.Client()    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')// Your API Endpoint    .setProject('<YOUR_PROJECT_ID>')// Your project ID    .setKey('<YOUR_API_KEY>');// Your secret API keyconst functions =new sdk.Functions(client);const result =await functions.update('<FUNCTION_ID>',// functionId'<NAME>',// name    sdk..Node145,// runtime (optional)    ["any"],// execute (optional)    [],// events (optional)'',// schedule (optional)1,// timeout (optional)false,// enabled (optional)false,// logging (optional)'<ENTRYPOINT>',// entrypoint (optional)'<COMMANDS>',// commands (optional)    [],// scopes (optional)'<INSTALLATION_ID>',// installationId (optional)'<PROVIDER_REPOSITORY_ID>',// providerRepositoryId (optional)'<PROVIDER_BRANCH>',// providerBranch (optional)false,// providerSilentMode (optional)'<PROVIDER_ROOT_DIRECTORY>',// providerRootDirectory (optional)''// specification (optional));

Update function's deployment

Update the function active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your function.

Endpoint
PATCH /functions/{functionId}/deployment
Node.js
const sdk =require('node-appwrite');const client =new sdk.Client()    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')// Your API Endpoint    .setProject('<YOUR_PROJECT_ID>')// Your project ID    .setKey('<YOUR_API_KEY>');// Your secret API keyconst functions =new sdk.Functions(client);const result =await functions.updateFunctionDeployment('<FUNCTION_ID>',// functionId'<DEPLOYMENT_ID>'// deploymentId);

List runtimes

Get a list of all runtimes that are currently active on your instance.

Endpoint
GET /functions/runtimes
Node.js
const sdk =require('node-appwrite');const client =new sdk.Client()    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')// Your API Endpoint    .setProject('<YOUR_PROJECT_ID>')// Your project ID    .setKey('<YOUR_API_KEY>');// Your secret API keyconst functions =new sdk.Functions(client);const result =await functions.listRuntimes();

List specifications

List allowed function specifications for this instance.

Endpoint
GET /functions/specifications
Node.js
const sdk =require('node-appwrite');const client =new sdk.Client()    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')// Your API Endpoint    .setProject('<YOUR_PROJECT_ID>')// Your project ID    .setKey('<YOUR_API_KEY>');// Your secret API keyconst functions =new sdk.Functions(client);const result =await functions.listSpecifications();

Create deployment

Create a new function code deployment. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you'll need to update the function's deployment to use your new deployment UID.

This endpoint accepts a tar.gz file compressed with your code. Make sure to include any dependencies your code has within the compressed file. You can learn more about code packaging in theAppwrite Cloud Functions tutorial.

Use the "command" param to set the entrypoint used to execute your code.

Endpoint
POST /functions/{functionId}/deployments
Node.js
const sdk =require('node-appwrite');const fs =require('fs');const client =new sdk.Client()    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')// Your API Endpoint    .setProject('<YOUR_PROJECT_ID>')// Your project ID    .setKey('<YOUR_API_KEY>');// Your secret API keyconst functions =new sdk.Functions(client);const result =await functions.createDeployment('<FUNCTION_ID>',// functionIdInputFile.fromPath('/path/to/file','filename'),// codefalse,// activate'<ENTRYPOINT>',// entrypoint (optional)'<COMMANDS>'// commands (optional));

Create duplicate deployment

Create a new build for an existing function deployment. This endpoint allows you to rebuild a deployment with the updated function configuration, including its entrypoint and build commands if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build.

Endpoint
POST /functions/{functionId}/deployments/duplicate
Node.js
const sdk =require('node-appwrite');const client =new sdk.Client()    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')// Your API Endpoint    .setProject('<YOUR_PROJECT_ID>')// Your project ID    .setKey('<YOUR_API_KEY>');// Your secret API keyconst functions =new sdk.Functions(client);const result =await functions.createDuplicateDeployment('<FUNCTION_ID>',// functionId'<DEPLOYMENT_ID>',// deploymentId'<BUILD_ID>'// buildId (optional));
Endpoint
POST /functions/{functionId}/deployments/template
Node.js
const sdk =require('node-appwrite');const client =new sdk.Client()    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')// Your API Endpoint    .setProject('<YOUR_PROJECT_ID>')// Your project ID    .setKey('<YOUR_API_KEY>');// Your secret API keyconst functions =new sdk.Functions(client);const result =await functions.createTemplateDeployment('<FUNCTION_ID>',// functionId'<REPOSITORY>',// repository'<OWNER>',// owner'<ROOT_DIRECTORY>',// rootDirectory'<VERSION>',// versionfalse// activate (optional));
Endpoint
POST /functions/{functionId}/deployments/vcs
Node.js
const sdk =require('node-appwrite');const client =new sdk.Client()    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')// Your API Endpoint    .setProject('<YOUR_PROJECT_ID>')// Your project ID    .setKey('<YOUR_API_KEY>');// Your secret API keyconst functions =new sdk.Functions(client);const result =await functions.createVcsDeployment('<FUNCTION_ID>',// functionId    sdk.VCSDeploymentType.Branch,// type'<REFERENCE>',// referencefalse// activate (optional));
Endpoint
GET /functions/{functionId}/deployments/{deploymentId}
Node.js
const sdk =require('node-appwrite');const client =new sdk.Client()    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')// Your API Endpoint    .setProject('<YOUR_PROJECT_ID>')// Your project ID    .setKey('<YOUR_API_KEY>');// Your secret API keyconst functions =new sdk.Functions(client);const result =await functions.getDeployment('<FUNCTION_ID>',// functionId'<DEPLOYMENT_ID>'// deploymentId);

Get deployment download

Get a function deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory.

List deployments

Get a list of all the function's code deployments. You can use the query params to filter your results.

Endpoint
GET /functions/{functionId}/deployments
Node.js
const sdk =require('node-appwrite');const client =new sdk.Client()    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')// Your API Endpoint    .setProject('<YOUR_PROJECT_ID>')// Your project ID    .setKey('<YOUR_API_KEY>');// Your secret API keyconst functions =new sdk.Functions(client);const result =await functions.listDeployments('<FUNCTION_ID>',// functionId    [],// queries (optional)'<SEARCH>'// search (optional));

Update deployment status

Cancel an ongoing function deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details.

Endpoint
PATCH /functions/{functionId}/deployments/{deploymentId}/status
Node.js
const sdk =require('node-appwrite');const client =new sdk.Client()    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')// Your API Endpoint    .setProject('<YOUR_PROJECT_ID>')// Your project ID    .setKey('<YOUR_API_KEY>');// Your secret API keyconst functions =new sdk.Functions(client);const result =await functions.updateDeploymentStatus('<FUNCTION_ID>',// functionId'<DEPLOYMENT_ID>'// deploymentId);

Create execution

Trigger a function execution. The returned object will return you the current execution status. You can ping theGet Execution endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously.

Endpoint
GET /functions/{functionId}/executions/{executionId}
Node.js
const sdk =require('node-appwrite');const client =new sdk.Client()    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')// Your API Endpoint    .setProject('<YOUR_PROJECT_ID>')// Your project ID    .setSession('');// The user session to authenticate withconst functions =new sdk.Functions(client);const result =await functions.getExecution('<FUNCTION_ID>',// functionId'<EXECUTION_ID>'// executionId);

List executions

Get a list of all the current user function execution logs. You can use the query params to filter your results.

Endpoint
GET /functions/{functionId}/executions
Node.js
const sdk =require('node-appwrite');const client =new sdk.Client()    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')// Your API Endpoint    .setProject('<YOUR_PROJECT_ID>')// Your project ID    .setSession('');// The user session to authenticate withconst functions =new sdk.Functions(client);const result =await functions.listExecutions('<FUNCTION_ID>',// functionId    []// queries (optional));
Endpoint
POST /functions/{functionId}/variables
Node.js
const sdk =require('node-appwrite');const client =new sdk.Client()    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')// Your API Endpoint    .setProject('<YOUR_PROJECT_ID>')// Your project ID    .setKey('<YOUR_API_KEY>');// Your secret API keyconst functions =new sdk.Functions(client);const result =await functions.createVariable('<FUNCTION_ID>',// functionId'<KEY>',// key'<VALUE>',// valuefalse// secret (optional));
Endpoint
GET /functions/{functionId}/variables/{variableId}
Node.js
const sdk =require('node-appwrite');const client =new sdk.Client()    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')// Your API Endpoint    .setProject('<YOUR_PROJECT_ID>')// Your project ID    .setKey('<YOUR_API_KEY>');// Your secret API keyconst functions =new sdk.Functions(client);const result =await functions.getVariable('<FUNCTION_ID>',// functionId'<VARIABLE_ID>'// variableId);
Endpoint
GET /functions/{functionId}/variables
Node.js
const sdk =require('node-appwrite');const client =new sdk.Client()    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')// Your API Endpoint    .setProject('<YOUR_PROJECT_ID>')// Your project ID    .setKey('<YOUR_API_KEY>');// Your secret API keyconst functions =new sdk.Functions(client);const result =await functions.listVariables('<FUNCTION_ID>'// functionId);
Endpoint
PUT /functions/{functionId}/variables/{variableId}
Node.js
const sdk =require('node-appwrite');const client =new sdk.Client()    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')// Your API Endpoint    .setProject('<YOUR_PROJECT_ID>')// Your project ID    .setKey('<YOUR_API_KEY>');// Your secret API keyconst functions =new sdk.Functions(client);const result =await functions.updateVariable('<FUNCTION_ID>',// functionId'<VARIABLE_ID>',// variableId'<KEY>',// key'<VALUE>',// value (optional)false// secret (optional));
On This Page

[8]ページ先頭

©2009-2025 Movatter.jp