@asbjornenge/tzkt-api
v1.0.4
Published
TzKTApi is a Node.js module to communicate with a [tzkt API](https://api.tzkt.io/).
Downloads
24
Readme
TzKTAPI
TzKTApi is a Node.js module to communicate with a tzkt API.
Heavily inspired by the dipdup-sdk.
It uses the openapi-typescript-codegen to generate the api code from the spec. It transpiles and modified this code to produce a module for Node.js in Javascript. It uses the module pattern.
It also exposes a wrapper around SignalR to ease consumption of the available websocket methods.
Install
npm i @asbjornenge/tzkt-api
Use
TzKTAPI
import { TzKTAPI } from '@asbjornenge/tzkt-api'
const api = new TzKTAPI({ BASE: 'https://api.tzkt.io' })
const contracts = await api.accounts.accountsGet({
type: 'contract',
limit: 10
})
console.log(contracts)
TzKTEvents
import { TzKTEvents } from '@asbjornenge/tzkt-api'
const events = new TzKTEvents({ BASE: 'https://api.tzkt.io/v1/events' })
await events.start()
events.on('head', async (head) => console.log(head))
await events.listen('head')
Test
npm test
enjoy.