Signing Requests

ChainStream uses API keys to authenticate all API calls. The Base API URL will be one of the following depending on your workspace environment type:

  • Mainnet: https://api-dex.chainstream.io/

Each API request must include the following headers:

  • Authorization - This value should be set to Bearer <Access Token>. The access token is a Base64 encoded JSON Web Token (JWT).

Generating JWT Token

You can generate a JWT token using the following code:

JavaScript

import { AuthenticationClient } from 'auth0';

const auth0Client = new AuthenticationClient({
    domain: `https://dex.asia.auth.chainstream.io/oauth/token`,
    client_id: 'your client id',
    client_secret: 'your client secret'
  });

const response = await auth0Client.oauth.clientCredentialsGrant({
      audience: 'https://api-dex.chainstream.io'
    });

return response.data.access_token;

Using SDKs

After generating the JWT token, you can use it to initialize the SDK:

JavaScript SDK

import { DexClient } from "@chainstream-io/dex";

const dex = new DexClient({
  accessToken: "your-jwt-token"  // Token generated from previous step
});

Make sure to replace the placeholder values with your actual API credentials.