Download OpenAPI specification:Download
Klaytn Node API helps BApp (Blockchain Application) developers to use the blockchain platform Klaytn without having to run a node themselves. Normally using Klaytn requires that you operate a Klaytn Endpoint Node (KEN) with a hardware with high-spec computing power. With Node API, you can start using the Klaytn platform without having to run a node. The functionality of the Node API endpoints enables you to do the following actions:
For more details on KAS, please refer to KAS Docs. If you have any questions or comments, please leave them in the KAS Developers Forum.
A common error titled Unauthorized
occurs regardless of API type if you have authorization issues.
401: Unauthorized
Code | Message | Description |
---|---|---|
1010009 | The credential you provided does not match in our record | The credential you provided is invalid. |
1010007 | The path or method in request is invalid. Check the service API documentation and try again. | Path or method is wrong. |
KAS uses Basic HTTP Auth. All requests must have a correct Authorization header. You can create the Credential for Basic Auth by using username
as AccessKey ID and password
as SecretAccessKey obtained on KAS Console.
NOTE
KAS Credential enables full access to KAS and the Klaytn accounts created using the Wallet API. It enables asset transfers of the Klaytn account's assets (like KLAY) as well as Transaction Executions. To keep your KAS/Klaytn accounts secure, do not share your KAS API Secret Access Key with others.
cURL
curl --location --request POST 'https://node-api.klaytnapi.com/v1/klaytn' \
-u {{your_accessKeyId}}:{{your_secretAccessKey}} \
--header 'x-chain-id: 8217' \
--header 'Content-Type: application/json' \
--data-raw '{"jsonrpc":"2.0","method":"klay_blockNumber","params":[],"id":1}'
caver-js
const accessKeyId = "{{your_accessKeyId}}";
const secretAccessKey = "{{your_secretAccessKey}}";
const option = {
headers: [
{name: 'Authorization', value: 'Basic ' + Buffer.from(accessKeyId + ':' + secretAccessKey).toString('base64')},
{name: 'x-chain-id', value: '8217'},
]
}
const caver = new Caver(new Caver.providers.HttpProvider("https://node-api.klaytnapi.com/v1/klaytn", option))
caver-java
HttpService httpService = new HttpService("https://node-api.klaytnapi.com/v1/klaytn");
String auth = Credentials.basic("{{your_accessKeyId}}", "{{your_secretAccessKey}}", StandardCharsets.UTF_8);
httpService.addHeader("Authorization", auth);
httpService.addHeader("x-chain-id", "8217")
Caver caver = Caver.build(httpService);
Security Scheme Type | HTTP |
---|---|
HTTP Authorization Scheme | basic |