JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q26971F
  • License MIT

steem api client

Package Exports

  • @blocker/steem-api

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@blocker/steem-api) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@blocker/steem-api

Modern and lightweight JavaScript library to consume the Steem API.

npm version Known Vulnerabilities Maintainability

Modern and lightweight JavaScript library to consume the Steem API.

Get started

Install

yarn add @blocker/steem-api node-fetch
# or
npm install @blocker/steem-api node-fetch

You can use any library that supports the WHATWG fetch specification.

Usage

import fetch from 'node-fetch'
import { HttpAdapter, ApiClient } from '@blocker/steem-api'

const adapter = new HttpAdapter({ fetch })
const client = new ApiClient({ adapter })

client.tags.getTrendingTags({ limit: 2 })
  .then(data => {

  })

demo RunKit

ApiClient

ApiClient uses Proxy and Reflect to simplify its use.

Send requests with Proxy feature

Syntax: client[api_name][method_name](params)

client.database_api.list_savings_withdrawals({ start: 10, limit: 55 })
  .then(result => {  })

You can omit the _api suffix in api_name and use camelCase in api_name and method_name.

client.database.listOwnerHistories({ start: 10, limit: 55 })
  .then(result => {  })

Send requests without Proxy feature

However it is possible to send requests without using this feature.

There are 3 ways to use the send method.

client.send(api_name, method_name, params)
client.send(full_method_name, params)
client.send(full_payload)

Exemples

client.send('database_api', 'list_savings_withdrawals', { start: 10, limit: 55 })
client.send('database_api.list_savings_withdrawals', { start: 10, limit: 55 })
client.send({
  method: 'database_api.list_savings_withdrawals',
  params: { start: 10, limit: 55 }
})

Adapters

ApiClient uses adapters to send requests. Currently the only available adapter is the HttpAdapter.

HttpAdapter

The HttpAdapter constructor receives the function an object as an argument, within that object the fetch instance must be passed as argument.

import fetch from 'node-fetch'
import { HttpAdapter } from '@blocker/steem-api'

const adapter = new HttpAdapter({ fetch })