Skip to content

API v1.0.0 index

Emily Liang edited this page Mar 23, 2023 · 10 revisions

TideBit-DeFi API v1.0.0

統一的Response格式

{
  "powerby": "TideBit-DeFi API v1.0.0",
  "success": true,
  "code": "00000000",
  "message": "Human-readable medium",
  "payload": {}
}

APIs

MarketContext

UserContext

GeneralContext

interfaces:

ITickerData

interface ITickerData {
  currency: string;
  chain: string;
  star: boolean;
  starred: boolean;
  price: number;
  upOrDown: ITrend;
  priceChange: number;
  fluctuating: number;
  tradingVolume: string;
  tokenImg: string;
  lineGraphProps: ILineGraphProps;
}

type ITrend = "UP" | "DOWN" | "EQUAL"

interface ILineGraphProps {
  dataArray?: number[];
  strokeColor?: string[];
  lineGraphWidth?: string;
  lineGraphWidthMobile?: string;
}

IApplyOrder

interface IApplyOrder {
  signature?: string;
}

IApplyCFDOrder

interface IApplyCFDOrder extends IApplyOrder{
    orderType: IOrderType;
    type: ICFDOrderType;
    data: ApplyCFDOrderData;
}

type IOrderType = 'CFD' | 'DEPOSIT' | 'WITHDRAW' | 'SPOT';

type ICFDOrderType = "CREATE" | "UPDATE" | "CLOSE"

type ApplyCFDOrderData =
  | IApplyCreateCFDOrderData
  | IApplyUpdateCFDOrderData
  | IApplyCloseCFDOrderData;

interface IApplyCreateCFDOrderData {
  ticker: string;
  quotation: IQuotation; // 報價單
  typeOfPosition: ITypeOfPosition;
  price: number;
  amount: number;
  targetAsset: string;
  uniAsset: string; // 計價單位(++TODO 有拼錯嗎?)
  margin: IMargin;
  leverage: number;
  liquidationPrice: number; // 強制平倉價格
  liquidationTime: number;
  guaranteedStop?: boolean;
  guaranteedStopFee?: number;
  createTimestamp?: number;
  takeProfit?: number;
  stopLoss?: number;
  fee: number;
  remark?: string;
}
  
interface IApplyUpdateCFDOrderData {
  orderId: string;
  takeProfit?: number;
  stopLoss?: number;
  guaranteedStop?: boolean;
  guaranteedStopFee?: number;
}
    
interface IApplyCloseCFDOrderData {
  orderId: string;
  closePrice: number;
  quotation: IQuotation;
  closeTimestamp?: number;
}
  
type ITypeOfPosition = 'BUY' | 'SELL';
    
interface IQuotation {
  ticker: string;
  targetAsset: string;
  uniAsset: string;
  price: number;
  deadline: number;
  signature: string;
}

interface IMargin {
  asset: string;
  amount: number;
}


IApplyDepositOrder

interface IApplyDepositOrder extends IApplyOrder {
  orderType: IOrderType;
  createTimestamp?: number;
  targetAmount: number;
  targetAsset: string; 
  decimals: number; 
  to: string; 
  remark: string;
  fee: number;
}

IApplyWithdrawOrder

interface IApplyWithdrawOrder extends IApplyOrder {
  orderType: IOrderType;
  createTimestamp?: number;
  targetAsset: string;
  targetAmount: number;
  to: string;
  remark?: string;
  fee: number;
}

IAcceptedOrder

interface IAcceptedOrder {
  id: string;
  orderType: IOrderType;
  createTimestamp: number;
  orderStatus: IOrderStatusUnion;
}

IAcceptedCFDOrder

interface IAcceptedCFDOrder extends IAcceptedOrder {
  ticker: string;
  state: IOrderState;
  typeOfPosition: ITypeOfPosition;
  targetAsset: string;
  uniAsset: string;
  openPrice: number;
  amount: number;
  leverage: number;
  margin: IMargin;
  takeProfit?: number;
  stopLoss?: number;
  fee: number;
  guaranteedStop: boolean;
  guaranteedStopFee?: number;
  liquidationPrice: number;
  liquidationTime: number;
  closePrice: number;
  closeTimestamp?: number;
  closedType?: ICFDClosedType;
  forcedClose?: boolean;
  remark?: string;
}

type ICFDClosedType =
  | 'SCHEDULE'
  | 'FORCED_LIQUIDATION'
  | 'STOP_LOSS'
  | 'TAKE_PROFIT'
  | 'BY_USER';

type IOrderState = 'OPENING' | 'CLOSED' | 'FREEZED';

IAcceptedDepositOrder

interface IAcceptedDepositOrder extends IAcceptedOrder {
  targetAsset: string;
  targetAmount: number;
  decimals: number;
  to: string;
  remark?: string;
  fee: number;
}

IAcceptedWithdrawOrder

interface IAcceptedWithdrawOrder extends IAcceptedOrder {
  targetAsset: string;
  targetAmount: number;
  to: string;
  remark?: string;
  fee: number;
}

ICryptocurrency

interface ICryptocurrency {
  id: string;
  icon: string; // svg src
  symbol: string; // USDT
  name: string; // Tether
  decimals: number; // decimal places
  contract: string;
  fee: number;
}

ICandlestickData

interface ICandlestickData {
  x: Date;
  open: number;
  high: number;
  low: number;
  close: number;
}

IBalance

interface IBalance {
  currency: string;
  available: number;
  locked: number;
}

INotification

interface INotification {
  id: string;
  timestamp: number;
  title: string;
  content: string;
  duration: [number, number];
  notificationLevel: INotificationLevel;
  isRead: boolean;
  public: boolean;
}

ITickerHistoryData

interface ITickerHistoryData {
  date: Date;
  open: number;
}

INews

interface INews {
  id: string;
  date: Date;
  title: string;
  subtitle: string;
  content: string;
}

ICourse

interface ICourse {
  id: string;
  date: Date;
  title: string;
  subtitle: string;
  description: string;
  url: string;
}

IIssue

interface IIssue {
  id: string;
  date: Date;
  title: string;
  email: string;
  subtitle: string;
  content: string;
}

ISubscribeData

interface ISubscribeData {
  type: "EMAIL_NOTIFICATIONS" | "NEWS_LETTERS";
  subscribe: boolean;
}

ITBEJob

interface ITBEJob {
  id: string,
  createDate: Date,
  jobTitle: string,
  location: string,
  salary: string,
  description: string,
}

IFAQs

interface IFAQs {
  id: string;
  question: string;
  answer: string
}