cd-sdk
v1.0.20
Published
A JavaScript SDK for integrating with the Axis platform
Readme
Axis SDK
The Axis SDK allows developers to easily integrate with the Axis platform. It provides methods to handle authentication, interact with financial data, and manage various platform features such as trading, order book, quotes, and funds.
Table of Contents
Installation
To install the Axis SDK, you can use either npm or yarn.
Using npm:
npm install axis-sdkUsing yarn:
yarn add axis-sdkInitialization
The Axis SDK provides two main ways of initializing:
- Without Token: This method initializes the SDK with basic configuration (login required).
- With Token: This method initializes the SDK using an authorization token for authentication.
SDK Configuration
interaction: The type of interaction mode (e.g.,'window','frame').client_id: A unique identifier for the client.authorization: The authorization token or credentials.credentials: An object containing tokens and account details:tokens: ContainstokenandrefreshToken.account: ContainssubAccountId.
Methods
init(config: SdkConfig): Promise<AxisSDKInstance>
Initializes the SDK without a token. This method requires interaction, client_id, and authorization as part of the configuration.
Parameters:
config(object): SDK configuration object.authorization: The authorization token.client_id: Unique identifier for the client.interaction: The interaction mode (either'window'or'frame').
Returns:
- A promise that resolves to an
AxisSDKInstanceobject with the SDK methods.
initWithToken(config: SdkConfigWithToken): Promise<AxisSDKInstanceWithoutLogin>
Initializes the SDK with a token. This method requires a full configuration, including tokens and account credentials.
Parameters:
config(object): Full SDK configuration object.authorization: The authorization token.client_id: Unique identifier for the client.interaction: The interaction mode (either'window'or'frame').credentials: Contains token and account information.
Returns:
- A promise that resolves to an
AxisSDKInstanceWithoutLoginobject.
Usage
SDK Initialization without Token
To initialize the SDK without a token, use the init method:
const sdk = await axisSDK.init({
authorization: 'your-authorization-token',
client_id: 'your-client-id',
interaction: 'window', // or 'frame'
});SDK Initialization with Token
To initialize the SDK with a token, use the initWithToken method:
const sdk = await axisSDKWithToken.initWithToken({
authorization: 'your-authorization-token',
client_id: 'your-client-id',
interaction: 'window', // or 'frame'
credentials: {
tokens: {
token: 'your-token',
refreshToken: 'your-refresh-token',
},
account: {
subAccountId: 'your-sub-account-id',
},
},
});Accessing SDK Methods
After initialization, you can access various SDK methods such as quotes, trade, orderbook, funds, holdings, and positions. Here’s an example of accessing the funds method:
const funds = await sdk.funds();If the SDK is initialized with a token:
const sdkWithToken = await axisSDKWithToken.initWithToken(config);
const funds = await sdkWithToken.funds();You can also use the logout method if the SDK is initialized with login credentials:
await sdk.logout();License
MIT License. See the LICENSE file for more details.
