@liskscan/lisk-service-client
v0.0.10
Published
Lisk service ts client
Downloads
24
Readme
Lisk Service client
This repository houses the TypeScript client for Lisk service, enabling seamless integration of Lisk blockchain data into your applications.
Installation
To add this package to your project, use either of the following commands:
Using npm:
npm install --save @liskscan/lisk-service-client
Using yarn:
yarn add @liskscan/lisk-service-client
Getting started
To start using the Lisk Service Client, you need to create a new service client:
import { LiskService } from "@liskscan/lisk-service-client"
const service = new LiskService({
url: "service.lisk.com",
disableTLS: true, // default false
disableWs: true, // default false
disableEvents: true // default false
})
Usage
HTTP Fetching
Retrieve blockchain blocks with a simple HTTP get request:
const getBlocks = async () => {
const blocks = await service.get("blocks", { limit: 25 })
if (blocks.status === "success") {
console.log(blocks.data)
}
}
getBlocks()
WS RPC Fetching
Leverage RPC over WebSockets to retrieve transactions:
const getTransactions = async () => {
const transactions = await service.rpc("get.transactions", { limit: 10 })
if (transactions.status === "success") {
console.log(transactions.data)
}
}
getTransactions()
Subscribing to Blockchain Events
Get real-time blockchain event updates:
service.subscribe("update.generators", (data) => {
console.log(data)
})
License
Copyright 2023 Liskscan BV.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.