Bit Capital

The Bit Capital Developer Hub

Welcome to the Bit Capital developer hub. You'll find comprehensive guides and documentation to help you start working with Bit Capital as quickly as possible, as well as support if you get stuck. Let's jump right in!

Guides    API Reference

Javascript SDK

The official SDK is used to access the Bitcapital Core services in JS and TS environments. It resided in the Bit Capital's Gitlab as an Open Source projects.

Getting Started

Install as a project dependency using Yarn, remember to specify the desired version.

# Install using Yarn (recommended)
yarn add "@bitapital/core-sdk";

# Install using NPM
npm install "@bitcapital/core-sdk";

Setting up your client

To start using this SDK you need both a Client ID and a Client Secret, emitted by the Bitcapital Core Team and the URL for the instance you're going to operate over. Every instance has its unique URL and previously authorized OAuth Clients.

If you don't have yours yet, checkout the guide on Requesting your credentials.

import Bitcapital, { User } from '@bitcapital/core-sdk';

// Initialize the session instance to authenticate
// using the Bitcapital Core OAuth 2.0 provider.
const bitcapital = Bitcapital.initialize({
  // Instance URL for REST API calls
  baseURL: 'https://your-instance.btcore.app',
  // Credentials for OAuth 2.0 requests
  clientId: '< YOUR CLIENT_ID HERE >',
  clientSecret: '< YOUR CLIENT_SECRET HERE >',
});

try {
  // Authenticate a user with email and password from Bitcapital Core
  // If succeeds and available, the credentials will be stored in the 
  // session instance and in the local storage (for browser environments).
  const user: User = await bitcapital.session().password({
    email: 'user@example.com',
    password: '12345678',
  });

  // The session returns the user info and credentials
  console.log(user.credentials.accessToken);
  
} catch(exception) {
  // Something went wront, probably credentials are invalid
  console.error(exception);
}

To destroy the current credentials for disposal of the client instance, use the session.destroy() method.

// This will trigger a session clean up
// All session subscribers will be notified asynchronously
await bitcapital.session().destroy();

Javascript SDK


The official SDK is used to access the Bitcapital Core services in JS and TS environments. It resided in the Bit Capital's Gitlab as an Open Source projects.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.