Flutter Satang Pro Exchange is a Flutter's library for calling API of the https://https://satang.pro
Add dependencies in pubspec.yaml
flutter_satang_pro_exchange: 1.1.0
Import the package to your project.
import 'package:flutter_satang_pro_exchange/satang_pro_exchange.dart';
Create instance without API Key.
var sp = SatangProExchangeService();
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 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 2 API keys with different permissions and trying to look your USER ID. Go to Developer Menu then create API KEY.
This API key are used for reading general information, such as balance, wallet address.
required permissions : READ WALLET , READ USER INFO.
Crate Order API key are used for creating order, such as balance, cancel orders ,
required permissions : READ/WRITE ORDER.
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: "---"));
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 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 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 with order id.
var response = await sp.cancelOrder(orderId: 1234567);
Suggestions for other uses.
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);
This package is UNOFFICIAL and the developer is not related with Satang.pro site.