@beincom/chain-client
v0.0.73
Published
Chain API Client SDK for Javascript
Maintainers
Keywords
Readme
Chain API Client SDK for Javascript
Getting started
Using npm:
$ npm install @beincom/chain-clientUsing yarn:
$ yarn add @beincom/chain-clientAfter installing the app, you can then import and use the SDK:
import { ChainApiClient } from '@beincom/chain-client';
const settings = {
baseUrl: '', // Replace with your BIC CHAIN API server.
};
const client = new ChainApiClient(settings);Creating a unique API Client
The ChainApiClient object returned by new ChainApiClient() provides access to the Chain API. An optional config object can be passed in when initializing to set your baseUrl, change the timeout, or specify the max number of retries.
Using the Chain API Client
The Chain API Client currently supports the following namespaces:
nft: NFT APIswallet: Wallet APIs
Chain API Client Settings
An ChainApiClientSettings object can be passed on instantiation to the ChainApiClient object, with the following optional parameters:
baseUrl: The base URL of the Chain API server.maxRetries: The maximum number of retries to attempt if a request fails. Defaults to 5.requestTimeout: Optional setting that sets the timeout for requests in milliseconds for the NFT and Notify namespaces. Defaults to no timeout.
Example usage of Chain API Client
import { ChainApiClient } from '@beincom/chain-client';
const chainClient = new ChainApiClient({
baseUrl: 'https://api.beincom.app/v1/chain',
})
.setPlatformHeaders({'x-language': 'en', 'x-platform': 'web'})
.includeCredentials();
const nfts = await client.nft.getNftsForOwner()