Package Exports
- @polkadot/api
- @polkadot/api/index
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 (@polkadot/api) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@polkadot/api
Warning - currently this does not actually do all that much, it is an attempt to put into code some thoughts about how to maintain the endpoints. This library provides a clean wrapper around all the methods exposed by a Polkadot network client.
Methods are auto-generated for the JsonRPC interface definitions, containing a full list of all sections and the methods contained within.
Usage
Installation -
npm install --save @polkadot/api
Initialisation -
import createApi from '@polkadot/api';
import HttpProvider from '@polkadot/api-provider/http';
const provider = new HttpProvider('http://127.0.0.1:9933');
const api = createApi(provider);
Making calls -
api.chain
.getHeader('0x1234567890')
.then((header) => console.log(header))
.catch((error) => console.error(error));