1.0.4 • Published 2 years ago

@asbjornenge/tzkt-api v1.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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.