API Request

This page introduces how to call KAS API by the demonstration of calling Wallet APIs that create a Klaytn account and get the account information.

Create Klaytn Account

Please sign up and log in KAS, and receive an API authentication key to create a Klaytn account.

An API authentication key can be created on KAS Console - Security - Credential menu, and the authentication password (Secret AccessKey) and Authorization can only be checked once upon their creation. Therefore, it is necessary to copy or download Secret AccessKey and Authorization to a safe location for proper and safe management after its creation. Authorization (e.g., Basic S0FTS1A2WkRaSjh...), which can be checked after creating an authentication key, refers to a value encoded using the AccessKey ID and Secret AccessKey through the basic authentication method and used for the call header when calling APIs.

A KAS API Authentication Key (API Auth Key) provides access to all KAS services and all the rights to a Klaytn account which was created by calling Wallet API via this API Auth Key. The rights here include accessing and transferring all the assets (KLAY, etc.) of or sending a transaction from a Klaytn account. If you shared your API Auth Key with any unauthorized personnel, your Klaytn account could be compromised and might cause unwanted transaction execution.

DO NOT share your API Auth Key (Secret AccessKey or Authorization) with any unauthorized personnel. DO PUT efforts necessary to keep your API Auth Key safe for the security of your KAS/Klaytn account.

For details about signing up, signing in, and getting API authentication key, please visit here.

API Request

When you have received your API authentication key, you could call the API that creates a Klaytn account with submitting this key in the API request header. If you already have created your own account pool in the KAS Console, you can call API and create a Klaytn account inside your custom account pool by specifying the KRN of your account pool as x-krn parameter in the API Request header. For details about using account pool and x-krn parameter, please visit here.

After creating an account pool in the KAS Console, call the Klaytn account creation API as follows. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.

KAS also provides a default account pool when you call the API with account pool. Account pool must be created first to use and manage personal account pool instead of using the default account pool.

  • The x-chain-id value for calling the API is 8217 (Cypress) or 1001 (Baobab).

  • Essential parameters for calling APIs are described in individual examples.

Values that a user needs to enter for calling APIs will be represented with one pair of braces ({}). A user must enter the following values.

Item

Description

Note

chain-id

8217 or 1001

Cypress (Klaytn mainnet) or Baobab (Klaytn testnet

access-key-id

Auth ID

accessKeyId obtained from KAS Console - Security - Credential

secret-access-key

Auth Password

secretAccessKey obtained from KAS Console - Security - Credential

krn

(optional) ID of account pool

Unnecessary when using default account pool

//Example of using the default account pool that KAS automatically generates for you. In this case, you can skip x-krn parameter.
curl --location --request POST "https://wallet-api.klaytnapi.com/v2/account" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}"

//Example of using your custom account pool that you have created in KAS Console. In this case, you should submit the KRN value of your account pool with x-krn parameter.
//Note that the account pool you first created in KAS Console is also designated as the default account pool, which is automatically selected when calling KAS API when you haven't specified x-krn parameter.
curl --location --request POST "https://wallet-api.klaytnapi.com/v2/account" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}"
--header "x-krn: krn:1001:wallet:6698d79e-78ee-439a-815d-f293ec6ae736:account-pool:ap1"

API Response

Here is a response of the Klaytn account creation API.

//Example API response when you have created a Klaytn account in the default account pool.
{
  "address": "0xa809284C83b901eD106Aba4Ccda14628Af128e14",
  "chainId": 1001,
  "createdAt": 1599187293,
  "keyId": "krn:1001:wallet:68ec0e4b-0f61-4e6f-ae35-be865ab23187:account-pool:default:0x4cbbcb974e32a7960e1b356edf60087613101919ed83199f12e872cba068a50f",
  "krn": "krn:1001:wallet:68ec0e4b-0f61-4e6f-ae35-be865ab23187:account-pool:default",
  "publicKey": "0x04cdccfb99b2905561e3dd886687b429a004718f11b04914f17ce68fd3a0db46c598a45da85caa61fe84cb78a0f2eaa9983ec7b8805a93ef9428eb1350a8558237",
  "updatedAt": 1599187293
}

//Example API response when you have created a Klaytn account in your own account pool.
{
  "address": "0xa809284C83b901eD106Aba4Ccda14628Af128e14",
  "chainId": 1001,
  "createdAt": 1599187293,
  "keyId": "krn:1001:wallet:6698d79e-78ee-439a-815d-f293ec6ae736:account-pool:ap1:0x4cbbcb974e32a7960e1b356edf60087613101919ed83199f12e872cba068a50f",
  "krn": "krn:1001:wallet:6698d79e-78ee-439a-815d-f293ec6ae736:account-pool:ap1",
  "publicKey": "0x04cdccfb99b2905561e3dd886687b429a004718f11b04914f17ce68fd3a0db46c598a45da85caa61fe84cb78a0f2eaa9983ec7b8805a93ef9428eb1350a8558237",
  "updatedAt": 1599187293
}

For details about this API, please visit here. For inquires about this document or KAS, please visit Developer Forum.

Get Information of a Klaytn Account

Klaytn account search API is used for searching for the information of a created Klaytn account.

API Request

Enter the address of account (EOA), and then call the Klaytn account search API. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.

  • The x-chain-id value for calling the API is 8217 (Cypress) or 1001 (Baobab).

  • Essential parameters for calling APIs are described in individual examples.

Values that a user needs to enter for calling APIs will be represented with one pair of braces ({}). A user must enter the following values.

Item

Description

Note

chain-id

8217 or 1001

Cypress (Klaytn mainnet) or Baobab (Klaytn testnet

access-key-id

Auth ID

accessKeyId obtained from KAS Console - Security - Credential

secret-access-key

Auth Password

secretAccessKey obtained from KAS Console - Security - Credential

krn

(optional) ID of account pool

Unnecessary when using default account pool

An API authentication key can be created on KAS Console - Security - Credential menu, and the authentication password (Secret AccessKey) and Authorization can only be checked once upon their creation. Therefore, it is necessary to copy or download Secret AccessKey and Authorization to a safe location for proper and safe management after its creation. Authorization (e.g., Basic S0FTS1A2WkRaSjh...), which can be checked after creating an authentication key, refers to a value encoded using the AccessKey ID and Secret AccessKey through the basic authentication method and used for the call header when calling APIs.

A KAS API Authentication Key (API Auth Key) provides access to all KAS services and all the rights to a Klaytn account which was created by calling Wallet API via this API Auth Key. The rights here include accessing and transferring all the assets (KLAY, etc.) of or sending a transaction from a Klaytn account. If you shared your API Auth Key with any unauthorized personnel, your Klaytn account could be compromised and might cause unwanted transaction execution.

DO NOT share your API Auth Key (Secret AccessKey or Authorization) with any unauthorized personnel. DO PUT efforts necessary to keep your API Auth Key safe for the security of your KAS/Klaytn account.

curl --location --request GET "https://wallet-api.klaytnapi.com/v2/account/0xa809284C83b901eD106Aba4Ccda14628Af128e14" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}"

API Response

Here is a response of the Klaytn account search API.

{
  "address": "0xa809284C83b901eD106Aba4Ccda14628Af128e14",
  "chainId": 1001,
  "createdAt": 1599187293,
  "keyId": "krn:1001:wallet:68ec0e4b-0f61-4e6f-ae35-be865ab23187:account-pool:default:0x4cbbcb974e32a7960e1b356edf60087613101919ed83199f12e872cba068a50f",
  "krn": "krn:1001:wallet:68ec0e4b-0f61-4e6f-ae35-be865ab23187:account-pool:default",
  "publicKey": "0x04cdccfb99b2905561e3dd886687b429a004718f11b04914f17ce68fd3a0db46c598a45da85caa61fe84cb78a0f2eaa9983ec7b8805a93ef9428eb1350a8558237",
  "updatedAt": 1599187293
}

For details about this API, please visit here. For inquires about this document or KAS, please visit Developer Forum.

Get List of Klaytn Accounts

Klaytn account list search API is used for looking for created Klaytn account lists.

API Request

Call the Klaytn account list search API. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.

  • The x-chain-id value for calling the API is 8217 (Cypress) or 1001 (Baobab).

  • Essential parameters for calling APIs are described in individual examples.

Values that a user needs to enter for calling APIs will be represented with one pair of braces ({}). A user must enter the following values.

Item

Description

Note

chain-id

8217 or 1001

Cypress (Klaytn mainnet) or Baobab (Klaytn testnet

access-key-id

Auth ID

accessKeyId obtained from KAS Console - Security - Credential

secret-access-key

Auth Password

secretAccessKey obtained from KAS Console - Security - Credential

krn

(optional) ID of account pool

Unnecessary when using default account pool

An API authentication key can be created on KAS Console - Security - Credential menu, and the authentication password (Secret AccessKey) and Authorization can only be checked once upon their creation. Therefore, it is necessary to copy or download Secret AccessKey and Authorization to a safe location for proper and safe management after its creation. Authorization (e.g., Basic S0FTS1A2WkRaSjh...), which can be checked after creating an authentication key, refers to a value encoded using the AccessKey ID and Secret AccessKey through the basic authentication method and used for the call header when calling APIs.

A KAS API Authentication Key (API Auth Key) provides access to all KAS services and all the rights to a Klaytn account which was created by calling Wallet API via this API Auth Key. The rights here include accessing and transferring all the assets (KLAY, etc.) of or sending a transaction from a Klaytn account. If you shared your API Auth Key with any unauthorized personnel, your Klaytn account could be compromised and might cause unwanted transaction execution.

DO NOT share your API Auth Key (Secret AccessKey or Authorization) with any unauthorized personnel. DO PUT efforts necessary to keep your API Auth Key safe for the security of your KAS/Klaytn account.

Query Parameter

You can receive API response values with cursor-based pagination. The search range can also be set by second.

Parameter

Description

Example

Required or Not

size

The number of items in the API response (min=1, max=1000, default=100)

size=100

False

cursor

The cursor required to get the next batch of response items

cursor=J9Ag...VM6z

False

to-timestamp

Search range: The last timestamp (sec)

to-timestamp=15921809920

False

from-timestamp

Search range: The first timestamp (sec)

from-timestamp=1592360291

False

curl --location --request GET "https://wallet-api.klaytnapi.com/v2/account?&size=100&cursor=&from-timestamp=1592360291&to-timestamp=15991809920" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}"

API Response

Here is the response of the Klaytn account list search API.

{
  "cursor": "",
  "items": [
    {
      "address": "0xa809284C83b901eD106Aba4Ccda14628Af128e14",
      "chainId": 1001,
      "createdAt": 1599187293,
      "keyId": "krn:1001:wallet:68ec0e4b-0f61-4e6f-ae35-be865ab23187:account-pool:default:0x4cbbcb974e32a7960e1b356edf60087613101919ed83199f12e872cba068a50f",
      "krn": "krn:1001:wallet:68ec0e4b-0f61-4e6f-ae35-be865ab23187:account-pool:default",
      "publicKey": "0x04cdccfb99b2905561e3dd886687b429a004718f11b04914f17ce68fd3a0db46c598a45da85caa61fe84cb78a0f2eaa9983ec7b8805a93ef9428eb1350a8558237",
      "updatedAt": 1599187293
    },
    {
      "address": "0x78B123CCCCd50f41E3192a60e6ED92B15E21b1B5",
      "chainId": 1001,
      "createdAt": 1599187194,
      "keyId": "krn:1001:wallet:68ec0e4b-0f61-4e6f-ae35-be865ab23187:account-pool:default:0x6c4419647e7724853f9e50b0c54b5985d0870470ac37b3ef865e62c3ccfa4ea4",
      "krn": "krn:1001:wallet:68ec0e4b-0f61-4e6f-ae35-be865ab23187:account-pool:default",
      "publicKey": "0x0463cc38f08dd15dfd416966e9d0da93942e26d2a9a9bcac08d614f487f94a7e46e4418d1acda9e21706f19c917486de40c974eb20c12a2eca2eea91895499d379",
      "updatedAt": 1599187194
    },
   ...
   ,
    {
      "address": "0x7ec5169EA28B2e3fFEF143a3513D7eC1CeFF2cB4",
      "chainId": 1001,
      "createdAt": 1599187161,
      "keyId": "krn:1001:wallet:68ec0e4b-0f61-4e6f-ae35-be865ab23187:account-pool:default:0xd3ee56e2616c8d412918e7f0e9222c805aacf5bad6d84b70b83c2229d61f21c9",
      "krn": "krn:1001:wallet:68ec0e4b-0f61-4e6f-ae35-be865ab23187:account-pool:default",
      "publicKey": "0x043ccf257d2ad3f8c3b2128969302efc6bf59d8cd8e578bcfdac8a4ac9cea6d4747350c98edaec5d23fafa9b3288a3b45816d2e9b3bb28443cc2486ad6bca652f1",
      "updatedAt": 1599187161
    }
  ]
}

For details about this API, please visit here. For inquires about this document or KAS, please visit Developer Forum.

Last updated