flutter_satang_pro_exchange 1.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 56

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.

1.1.0 #

Add marketcap API.

1.0.2 #

Fix balance bug.

1.0.1 #

Return response when create/cancel order.

1.0.0 #

Wallet API.

example/README.md

flutter_satang_pro_exchange_example #

Demonstrates how to use the flutter_satang_pro_exchange plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_satang_pro_exchange: ^1.1.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_satang_pro_exchange/dao/api_key/satang_pro_api_key.dart';
import 'package:flutter_satang_pro_exchange/dao/errors/satang_pro_error_dao.dart';
import 'package:flutter_satang_pro_exchange/dao/errors/satang_pro_response_error_support.dart';
import 'package:flutter_satang_pro_exchange/dao/market_open_order/satang_pro_market_open_orders_dao.dart';
import 'package:flutter_satang_pro_exchange/dao/market_open_order/satang_pro_open_order_item_dao.dart';
import 'package:flutter_satang_pro_exchange/dao/satang_pro_currency_pair_dao.dart';
import 'package:flutter_satang_pro_exchange/dao/satang_pro_market_cap_currency_dao.dart';
import 'package:flutter_satang_pro_exchange/dao/user_information/identity/satang_pro_user_address_dao.dart';
import 'package:flutter_satang_pro_exchange/dao/user_information/identity/satang_pro_user_district_dao.dart';
import 'package:flutter_satang_pro_exchange/dao/user_information/identity/satang_pro_user_province_dao.dart';
import 'package:flutter_satang_pro_exchange/dao/user_information/identity/satang_pro_user_sub_district_dao.dart';
import 'package:flutter_satang_pro_exchange/dao/user_information/satang_pro_user_identity_dao.dart';
import 'package:flutter_satang_pro_exchange/dao/user_information/satang_pro_user_information_dao.dart';
import 'package:flutter_satang_pro_exchange/dao/user_information/satang_pro_user_limit_currency_dao.dart';
import 'package:flutter_satang_pro_exchange/dao/user_information/satang_pro_user_limit_currency_item_dao.dart';
import 'package:flutter_satang_pro_exchange/dao/user_information/satang_pro_user_wallet_dao.dart';
import 'package:flutter_satang_pro_exchange/dao/user_open_orders/satang_pro_user_open_order_dao.dart';
import 'package:flutter_satang_pro_exchange/dao/user_open_orders/satang_pro_user_open_order_item_dao.dart';
import 'package:flutter_satang_pro_exchange/dao/wallets/satang_pto_wallet_dao.dart';
import 'package:flutter_satang_pro_exchange/satang_pro_auth_utils.dart';
import 'package:flutter_satang_pro_exchange/satang_pro_currency.dart';
import 'package:flutter_satang_pro_exchange/satang_pro_currency_pair.dart';
import 'package:flutter_satang_pro_exchange/satang_pro_exchange.dart';
import 'package:flutter_satang_pro_exchange/satang_pro_open_order_type.dart';
import 'package:flutter_satang_pro_exchange/satang_pro_order_type.dart';
import 'package:flutter_satang_pro_exchange/satang_pro_utils.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
14
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
97
Overall:
Weighted score of the above. [more]
56
Learn more about scoring.

We analyzed this package on Dec 9, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.6

Health suggestions

Fix lib/dao/user_information/satang_pro_user_information_dao.dart. (-0.50 points)

Analysis of lib/dao/user_information/satang_pro_user_information_dao.dart reported 1 hint:

line 1 col 8: Unused import: 'package:flutter_satang_pro_exchange/dao/errors/satang_pro_error_dao.dart'.

Fix lib/satang_pro_auth_utils.dart. (-0.50 points)

Analysis of lib/satang_pro_auth_utils.dart reported 1 hint:

line 1 col 8: Unused import: 'dart:convert'.

Fix lib/satang_pro_currency_pair.dart. (-0.50 points)

Analysis of lib/satang_pro_currency_pair.dart reported 1 hint:

line 4 col 48: Name non-constant identifiers using lowerCamelCase.

Fix additional 18 files with analysis or formatting issues. (-0.50 points)

Additional issues in the following files:

  • lib/satang_pro_exchange.dart (1 hint)
  • lib/dao/api_key/satang_pro_api_key.dart (Run flutter format to format lib/dao/api_key/satang_pro_api_key.dart.)
  • lib/dao/errors/satang_pro_error_dao.dart (Run flutter format to format lib/dao/errors/satang_pro_error_dao.dart.)
  • lib/dao/market_open_order/satang_pro_market_open_orders_dao.dart (Run flutter format to format lib/dao/market_open_order/satang_pro_market_open_orders_dao.dart.)
  • lib/dao/market_open_order/satang_pro_open_order_item_dao.dart (Run flutter format to format lib/dao/market_open_order/satang_pro_open_order_item_dao.dart.)
  • lib/dao/satang_pro_currency_pair_dao.dart (Run flutter format to format lib/dao/satang_pro_currency_pair_dao.dart.)
  • lib/dao/user_information/identity/satang_pro_user_address_dao.dart (Run flutter format to format lib/dao/user_information/identity/satang_pro_user_address_dao.dart.)
  • lib/dao/user_information/identity/satang_pro_user_district_dao.dart (Run flutter format to format lib/dao/user_information/identity/satang_pro_user_district_dao.dart.)
  • lib/dao/user_information/identity/satang_pro_user_province_dao.dart (Run flutter format to format lib/dao/user_information/identity/satang_pro_user_province_dao.dart.)
  • lib/dao/user_information/identity/satang_pro_user_sub_district_dao.dart (Run flutter format to format lib/dao/user_information/identity/satang_pro_user_sub_district_dao.dart.)
  • lib/dao/user_information/satang_pro_user_identity_dao.dart (Run flutter format to format lib/dao/user_information/satang_pro_user_identity_dao.dart.)
  • lib/dao/user_information/satang_pro_user_limit_currency_dao.dart (Run flutter format to format lib/dao/user_information/satang_pro_user_limit_currency_dao.dart.)
  • lib/dao/user_information/satang_pro_user_limit_currency_item_dao.dart (Run flutter format to format lib/dao/user_information/satang_pro_user_limit_currency_item_dao.dart.)
  • lib/dao/user_open_orders/satang_pro_user_open_order_dao.dart (Run flutter format to format lib/dao/user_open_orders/satang_pro_user_open_order_dao.dart.)
  • lib/dao/user_open_orders/satang_pro_user_open_order_item_dao.dart (Run flutter format to format lib/dao/user_open_orders/satang_pro_user_open_order_item_dao.dart.)
  • lib/dao/wallets/satang_pto_wallet_dao.dart (Run flutter format to format lib/dao/wallets/satang_pto_wallet_dao.dart.)
  • lib/satang_pro_currency.dart (Run flutter format to format lib/satang_pro_currency.dart.)
  • lib/satang_pro_open_order_type.dart (Run flutter format to format lib/satang_pro_open_order_type.dart.)

Maintenance suggestions

The package description is too short. (-3 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
http ^0.12.0+2 0.12.0+2
pointycastle ^1.0.1 1.0.2
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.11 1.14.12
http_parser 3.1.3
meta 1.1.7 1.1.8
path 1.6.4
pedantic 1.9.0
sky_engine 0.0.99
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test