Flutter Satang Pro Exchange

Flutter Satang Pro Exchange is a Flutter's library for calling API of the https://https://satang.pro

Installation

Add dependencies in pubspec.yaml

flutter_satang_pro_exchange: 1.1.0

Usage

Import the package to your project.

import 'package:flutter_satang_pro_exchange/satang_pro_exchange.dart';

Using Public API

Create instance without API Key.

var sp = SatangProExchangeService();

Get Market cap.

last coin price , volume , percent change.

  var market = await sp.fetchMarket();
      market.avg24hr;
      market.baseVolume;
      market.high24hr;
      market.highestBid;
      market.last;
      market.low24hr;
      market.lowestAsk;
      market.percentChange;
      market.quoteVolume;
}

Get Open Order in Market

Get market open order bids and asks.

This is a public API. you can access JSON in https://api.tdax.com/api/orders/?pair=btc_thb directly.

[GET]
https://api.tdax.com/api/orders/?pair=SYMBOL
  SatangProMarketOpenOrdersDao market = await sp.fetchMarketOpenOrders(pair: "btc_thb");
  var bids = market.bids; // list sell order.
  var asks = market.asks; // list buy order.
}

Get price and amount in order.

  for(var order in bids){
    // order.price;
    // order.amount;
  }
}

Prepare Private API

Prepare 2 API keys with different permissions and trying to look your USER ID. Go to Developer Menu then create API KEY.

1. User Information API key

This API key are used for reading general information, such as balance, wallet address.

required permissions : READ WALLET , READ USER INFO.

2. Order's API key

Crate Order API key are used for creating order, such as balance, cancel orders ,

required permissions : READ/WRITE ORDER.

Using Private API

Create instance with 2 API keys and user id. Your user id will be in Developer Menu.

var sp = SatangProExchangeService(
                userId: 7892,
                apiKeyUserInfo: SatangProApiKey(apiKey: "---", secret: "---"),
                apiKeyOrder: SatangProApiKey(apiKey: "---", secret: "---"));

Get User Information and Wallet

Return user information such as email, user id , verify level and wallet data.

  var userInfo = await sp.fetchUserInformation();
  if(!userInfo.isError){
    // userInfo.email;
    // userInfo.id;
    // userInfo.identityVerificationLevel;
    // userInfo.wallets;
    // userInfo.identity;
  }else{
    // userInfo.error.code;
    // userInfo.error.message;
  }

Get balance and wallet's addresses.

     var wallets = userInfo.wallets.list;
     for(var wallet in wallets){
       // wallet.currency;   // BTC
       // wallet.availableBalance;  // 0.001
       /// wallet.addresses; // 365CKrHsS8gqMaETsuPVoeUcFxh4nAEaKu
     }

Get Order List

Get current order and order history.

Order Type

SatangProOrderType.BUY
SatangProOrderType.SELL

Using fetch orders.

  var myOrders = await sp.fetchOrders(pair: "btc_thb",orderType: SatangProOrderType.BUY);
  if(!myOrders.isError){
    for(var order in myOrders.orders){
      // order.id;
      // order.amount;
      // order.price;
      // order.type;
      // order.status;
      // order.remainingAmount;
    }
  }else{
    // userInfo.error.code;
    // userInfo.error.message;
  }

Create Order

Create order to market.

  // create order BUY 0.0005 BTC with 100,000 THB
  var response = await sp.createOrder(pair: "btc_thb",
      orderType: SatangProOrderType.BUY,
      amount: 0.0005,
      price: 100000);

Cancel Order

Cancel order with order id.

 var response = await sp.cancelOrder(orderId: 1234567);

Other uses

Suggestions for other uses.

Pairing Currency

You can use the atangProCurrency class instead of pair text.

Example

var market = await sp.fetchMarketOpenOrders(pair: SatangProCurrency.BTC_THB);

Pair supported.

    BTC_THB
    ETH_THB
    USDT_THB
    XLM_THB
    XRP_THB
    XZC_THB

display JSON response on console or logcat.

await sp.fetchMarketOpenOrders(printJson: true);

More

This package is UNOFFICIAL and the developer is not related with Satang.pro site.

Libraries

satang_pro_api_key
satang_pro_auth_utils
satang_pro_currency
satang_pro_currency_pair
satang_pro_currency_pair_dao
satang_pro_error_dao
satang_pro_exchange
satang_pro_market_cap_currency_dao
satang_pro_market_open_orders_dao
satang_pro_open_order_item_dao
satang_pro_open_order_type
satang_pro_order_type
satang_pro_response_error_support
satang_pro_user_address_dao
satang_pro_user_district_dao
satang_pro_user_identity_dao
satang_pro_user_information_dao
satang_pro_user_limit_currency_dao
satang_pro_user_limit_currency_item_dao
satang_pro_user_open_order_dao
satang_pro_user_open_order_item_dao
satang_pro_user_province_dao
satang_pro_user_sub_district_dao
satang_pro_user_wallet_dao
satang_pro_utils
satang_pto_wallet_dao