The Bloq platform presents a set of infrastructure power-tools for building on multiple blockchain networks. This how-to series will largely focus on Bloq Connect, our managed API service for blockchain connectivity.
A Bloq account is required to interact with the platform, so we’ll start there. Through the account, users can generate keys and tokens that authorize access to Bloq API endpoints. Below, we’ll walk through the steps required to set up your account and get started on Bloq for the first time. You’ll find that most articles in this series will reference this one to ensure you get the best possible start.
Create a Bloq Account
First time users must sign up for a Bloq account here. To sign up for an account, you’ll need to provide your name, email, and billing address, as well as a password. (Don’t worry about the billing — Bloq Connect is free for most users’ needs when starting out and the cost for greater levels of use is incremental.) After filling out the sign up form, you’ll receive an activation link in your email.
There are several plans available that provide varying limits for Connect usage. Again, for most users starting out, the free plan is more than enough.
Client Keys via Console
After signing up and activating a plan, users can also generate their Client Keys through the Bloq Console.
From the main dashboard, navigate to “IAM” under the “Account” tab.
IAM, or Identity Access Management, is the central hub to manage and create client id/secret pairs.
Create a new key with the “New Key” button.
Now you’ve got a new set of keys! Make sure to copy down the id/secret somewhere safe. You won’t be able to recover the “secret” component after you navigate away from the pop-up.
Generate Tokens via Console
Lastly, users may generate Client Access Tokens from the Console website.
From the home page, navigate to Connect through the left hand sidebar.
From the Connect dashboard, navigate to the bottom of the page in order to generate a Client Access Token.
A pop-up will appear containing the Client Access Token. Copy it down somewhere safe and accessible and you’re good to go!
Installing the Command Line Interface
With an active account, you can now access the Bloq Command Line, which enables users to execute commands directly to their terminal.
Through your command prompt execute the following to install the CLI:
npm i -g @bloq/cloud-cli
Please note that you must have a recent installation of Node.js and npm to install properly.
You can double check that installation completed successfully with
Login and Keys/Token Generation via CLI
With the CLI installed, login to your account with
bcl login -u email@example.com.
Input your password when prompted, and your Bloq account is now synced up to the CLI.
The different APIs that make up Bloq Connect require authorization to use. To grant authorization, you’ll need to supply client keys and access tokens.
First, generate a client id/secret pair with
bcl client-keys create. You’ll be asked whether you’d like to store your keys locally. Input ‘y’ to agree.
With your newly created client keys, generate a Client Access Token with
bcl client-token. The Client Access Token is a short-term authorization token required for Websockets and REST API commands.
Client Access tokens expire after an hour, so you’ll need to refresh the token or generate a new one for sustained activities.
Generating new client tokens is no issue for regular use, but for automated applications or software that creates queries and submissions over time, refreshing the token becomes much more efficient than creating a new one every hour.
Tokens can be refreshed through the Bloq Accounts REST API. Execute the following command in your terminal with a valid refresh token to generate a new Client Access Token:
That’s it! Easy, right? With a Bloq account, the CLI installed, and newly generated client keys and access tokens, you’ve passed all the checkpoints required to start interacting with various blockchains through the Bloq platform.
Check out the Technical Reference in our documentation to get an idea of the different toolkits available through Bloq. Next, we’ll start simple with learning how to query Bitcoin and Bitcoin Cash to retrieve a balance.