Search…
Javascript SDK
The Bloq Javascript SDK enables you to work with Bloq services easily by simplifying authentication.

Requirements

The Javascript SDK has the following system requirements to install the library:

Install

To install the Bloq Javascript SDK, use either:
npm install --save @bloq/cloud-sdk
OR
yarn add @bloq/cloud-sdk

Use

const { auth, connect } = require('@bloq/cloud-sdk')
const clientId = 'CLIENT_ID'
const clientSecret = 'CLIENT_SECRET'
const connectClient = connect.http({
auth: {
clientId,
clientSecret
},
coin: 'btc',
network: 'mainnet'
})

Auth API

The auth API helps to simplify the authentication process.

Access Token

accessToken()
This method returns a promise that resolves in a new created access token using the provided client ID and secret.
The Access Token is required to interact with Bloq services. It usually travels in an Authorization header value.
Code sample
const { auth } = require('@bloq/cloud-sdk')
const clientId = 'CLIENT_ID'
const clientSecret = 'CLIENT_SECRET'
const client = auth({ clientId, clientSecret })
client.accessToken().then(function (accessToken) {
// Use access token
})
Copy link
On this page
Requirements
Install
Use
Auth API