Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Cloud Functions
  • Getting started
    • Overview
    • Creating and executing functions
    • Creating a timer
    • Creating a trigger for Yandex Message Queue
    • Creating a trigger for Object Storage
    • Creating a trigger for Container Registry
    • Creating a trigger for Cloud Logs
    • Creating a trigger for IoT Core
  • Step-by-step instructions
    • All instructions
    • Using functions to get an IAM token for a service account
    • Managing rights to access functions
    • Managing functions
      • Creating a function
      • Managing function versions
      • Working in the code editor
      • Invoking a function
      • Updating a function
      • Viewing monitoring charts
      • Viewing the execution log
      • Deleting a function
    • Managing triggers
      • Getting information about a trigger
      • Creating a timer
      • Creating a trigger for Message Queue
      • Creating a trigger for Object Storage
      • Creating a trigger for Container Registry
      • Creating a trigger for Cloud Logs
      • Creating a trigger for Yandex IoT Core
      • Updating a trigger
      • Deleting a trigger
  • Concepts
    • Overview
    • Functions
    • Invoking a function
    • Runtime environment
      • Overview
      • Environment
      • Execution context
    • Builder
    • Triggers
      • Overview
      • Timer
      • Trigger for Message Queue
      • Trigger for Object Storage
      • Trigger for Container Registry
      • Trigger for Cloud Logs
      • Trigger for Yandex IoT Core
    • Log groups
    • Monitoring
    • Backups
    • Quotas and limits
  • Developing in Node.js
    • Overview
    • Managing dependencies
    • Request handlers
    • Invocation context
    • Logging
    • Handling errors
    • Using the SDK
  • Developing in Python
    • Overview
    • Managing dependencies
    • Request handlers
    • Invocation context
    • Logging
    • Handling errors
    • Using the SDK
  • Developing in Go
    • Overview
    • Managing dependencies
    • Request handlers
    • Invocation context
    • Logging
    • Handling errors
    • Using the SDK
  • Developing in PHP
    • Overview
    • Managing dependencies
    • Request handlers
    • Invocation context
    • Logging
    • Handling errors
  • Developing in Bash
    • Overview
    • Request handlers
    • Logging
    • Handling errors
    • Using the SDK
  • Developing in Java
    • Overview
    • Java programming model
      • Overview
      • Using the Function interface to set a handler function
      • Using the YcFunction interface to set a handler function
      • Using the HttpServlet class to set a handler
      • Using the SpringBootApplication annotation to set a handler
    • Managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Handling errors
    • Using the SDK
  • Developing in R
    • Overview
    • R programming model
    • Building and managing dependencies
    • Request handler
    • context.md
    • Logging
    • Handling errors
  • Developing in C#
    • Overview
    • C# programming model
      • Overview
      • Using the Function interface to set a handler function
      • Using the YcFunction interface to set a handler function
    • Building and managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Handling errors
    • Using the SDK
  • Use cases
    • Creating skills for Alice
  • Pricing policy
  • Access management
  • API Functions reference
    • Authentication in the API
    • gRPC
      • Overview
      • FunctionService
      • OperationService
    • REST
      • Overview
      • Function
        • Overview
        • create
        • createVersion
        • delete
        • get
        • getVersion
        • getVersionByTag
        • list
        • listAccessBindings
        • listOperations
        • listRuntimes
        • listTagHistory
        • listVersions
        • removeTag
        • setAccessBindings
        • setTag
        • update
        • updateAccessBindings
  • API Triggers reference
    • Authentication in the API
    • gRPC
      • Overview
      • TriggerService
      • OperationService
    • REST
      • Overview
      • Trigger
        • Overview
        • create
        • delete
        • get
        • list
        • listOperations
        • pause
        • resume
        • update
  • Questions and answers
  1. Developing in Node.js
  2. Using the SDK

Using the SDK

    The runtime environment has a pre-installed library that lets you access the Yandex.Cloud API. To use it, you don't need to add dependencies to your application, except when a library version other than that of the pre-installed one is required. You can find the library source code on GitHub.

    Software development kits (SDK) let you interact with Yandex.Cloud services using the service account specified in the function. For example, you can get a list of available clouds (similar to the yc resource-manager cloud list command):

    const {CloudService} = require("yandex-cloud/api/resourcemanager/v1");
    
    module.exports.handler = async function (event, context) {
        const cloudService = new CloudService();
        const clouds = await cloudService.list({});
    
        return {
            clouds,
        };
    };
    

    To make local debugging easier and reduce the volume of the function code to upload, add the yandex-cloud package to the package.json file in the devDependencies section:

    {
      "name": "my-app",
      "version": "1.0.0",
      "devDependencies": {
        "yandex-cloud": "^1.4"
      }
    }
    
    Language
    Careers
    Privacy policy
    Terms of use
    © 2021 Yandex.Cloud LLC