SDKs
JavaScript/Typescript
Admin Methods
Projects (Brands)
Management

Projects

A project (sometimes referred to as a brand) in TradrAPI represents a single app or website which uses TradrAPI.

Each project has a unique ID and a UID (unique identifier) and can be linked with multiple trading platforms and multiple servers based on the project's requirements.

⚠️

In order to list or create new projects under TradrAPI, manager level authentication is required.

Fetching projects

To fetch a single project, use the get method available under the admin.brand namespace. The method accepts a single parameter which is the ID of the project to fetch. For example:

import { Brand } from '@tradrapi/trading-sdk';
 
const brand: Brand = await tradrApi.admin.brand.get(9);

The response will be a Brand object which contains the following properties:

interface Brand {
  /** The TradrAPI ID of the entity */
  id: number;
  /**
   * The date the entity was created
   * @format date-time
   */
  createdAt: string;
  /**
   * The date the entity was last updated
   * @format date-time
   */
  updatedAt: string;
  /** Whether the brand is active or not */
  active: boolean;
  /** The name of the brand */
  name: string;
  /** The unique identifier of the brand */
  uid: string;
  /** The unique identifier of the brand on the exchange */
  exchangeUid: string;
  /** If JWT auth for users is required, the url of the jwks endpoint to use */
  jwksUrl: string;
  /** If JWT auth for users is required, the issuer to use for JWT tokens */
  jwksIss: string;
  /** The account category types which should be supported */
  accountCategories?: AccountCategory;
  /** The exchanges (trading platforms) which the brand will use */
  exchanges?: Exchange[];
  /** The default exchange for the brand */
  defaultExchange: Exchange;
  /** The default exchange id for the brand */
  defaultExchangeId: number;
  /** The admin level api keys assigned to the brand */
  apiKeys?: BrandApiKey[];
  /** The supported currencies */
  currencies?: Currency[];
  /** The supported countries */
  countries?: Country[];
  /** The rules which define account routing during registration */
  rules?: Rule[];
  /** The spread groups assigned to the brand */
  spreadGroups?: SpreadGroup[];
}

To list all projects under TradrAPI, use the list method available under the admin.brand namespace, for example:

import { PaginatedResponse, Brand } from '@tradrapi/trading-sdk';
 
const brands: PaginatedResponse<Brand> = await tradrApi.admin.brand.list();

The list() method accepts an optional ListBrandDto parameter which can be used to filter and paginate the results, the available options are:

interface ListBrandDto {
  /**
   * The current page being returned.
   * @default 1
   */
  page?: number;
  /**
   * Number of records per page.
   * @default 10
   */
  limit?: number;
  /**
   * The sort direction of the records being returned
   * @default "DESC"
   */
  sortDir?: SortDir;
  /** Filter by a specific brand ID */
  brandId?: number;
  /** Filter by a specific brand name */
  name?: string;
  /** Filter by a specific brand UID (unique identifier) */
  uid?: string;
  /** Filter by a specific default exchange */
  defaultExchangeId?: number;
}

Fetching A Project's Default Group

⚠️

The concept of a default group assigned to a Project (brand) is deprecated and will be removed in a future version of TradrAPI.

To fetch a project's default group ID, use the getDefaultGroup method available under the admin.brand namespace. The method accepts a single parameter which is the ID of the project to fetch the default group for. For example:

const defaultGroupId: number = await tradrApi.admin.brand.defaultGroup();

Updating Projects

To update a project, use the update method available under the admin.brand namespace. The method accepts a UpdateBrandDto parameter which contains the properties to update. For example:

const result: boolean = await tradrApi.admin.brand.update({
  brandId: 9,
  name: 'My New Brand Name',
});

The UpdateBrandDto parameter accepts the following properties:

interface UpdateBrandDto {
  /** The ID of the brand to update */
  brandId: number;
  /** Whether to set the brand as active or not */
  active?: boolean;
  /** The UID to use with the brand on the relevant exchanges */
  exchangeUid?: string;
  /**
   * The name of the brand
   * @minLength 1
   */
  name?: string;
  /**
   * The UID of the brand within TradrAPI. Note, changing this will re-create brand groups
   * @minLength 1
   * @maxLength 5
   * @example "BRD"
   */
  brandUid?: string;
  /** If JWT auth for users is required, the url of the jwks endpoint to use */
  jwksUrl?: string | null;
  /**
   * If JWT auth for users is required, the issuer to use for JWT tokens
   * @minLength 3
   */
  jwksIss?: string | null;
  /** The ID of the default exchange to link this brand to */
  defaultExchange?: number;
  /** The IDs of the exchanges to link this brand to */
  exchanges?: number[];
}