API Calls with SDK

This page explains how to make a KAS API call using KAS SDK. Create a Klaytn account and take a look at the tutorial for getting account information.

Access Key

To use KAS API, you have to create a default account and set authorization. Create your account on KAS Console, or use KAS SDKs Caver-js-ext-kas or Caver-java-ext-kas. On this page, we will show your how to use KAS SDK.

First set "chain id" and "Access Key". You can initialize them as shown below. Pass chainId, accessKeyId and secretAccessKey to the constructor and it will call the caver.initKASAPI function. This function will initialize the access keys used for Klaytn Node API, Wallet API, Token History API, Anchor API, KIP-17 API, KIP-7 API, and KIP-37 API all at once.

  • Set access key with constructor

// Set authorization through constructor
const caver = new CaverExtKAS(chainId, accessKeyId, secretAccessKey);
// Set authorization through constructor
CaverExtKAS caver = new CaverExtKAS(chain, accessKeyId, secretAccessKey);
  • Set access key with caver.initKASAPI

// Set an authorization through 'caver.initKASAPI' function
const caver = new CaverExtKAS();
caver.initKASAPI(chainId, accessKeyId, secretAccessKey);

Below you see the initialization processes for KAS API Service. You can optionally pass the endpoint URL in the pass parameter. Otherwise, it will be set to KAS Production URL as default.

KAS Production URL

  • Node API: https://node-api.klaytnapi.com

  • Wallet API: https://wallet-api.klaytnapi.com

  • Anchor API: https://anchor-api.klaytnapi.com

  • Token History API: https://th-api.klaytnapi.com

  • KIP-17 API: https://kip17-api.klaytnapi.com

  • KIP-7 API: https://kip7-api.klaytnapi.com

  • KIP-37 API: https://kip37-api.klaytnapi.com

Create and Get Account

You can create an account using KAS Wallet API as shown below:

Running the above code returns the following account information:

If you have any inquiries on this document or KAS in general, please visit KAS Developers Forum.

Last updated

Was this helpful?