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--requestPOST"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--requestPOST"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"
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}"
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}"